url-redirection


Apache2 ProxPassReverse with tomcat redirection and context


I'm not able to configure correctly my apache2 reverse proxy for a context tomcat application.
I'm using the url www.projet-okinawa.ch in browser to externally access the application.
My tcp port 80 is routed to 8080 by iptables.
(sudo iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080)
I defined a virtual host to catch the url www.projet-okinawa.ch from the port 8080 and redirect the request to the ssl port.
<VirtualHost *:8080>
ServerName www.projet-okinawa.ch
ServerAlias projet-okinawa.ch
Redirect permanent / https://www.projet-okinawa.ch:8443/
</VirtualHost>
I defined a second virtual host to catch the same url from the port 8443 that enable ssl and manage the reverse proxy.
<VirtualHost *:8443>
ServerName www.projet-okinawa.ch
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://web.projet-okinawa.org:8081/okinawa
ProxyPassReverse / http://web.projet-okinawa.org:8081/okinawa
<Location />
Order allow,deny
Allow from all
</Location>
SSLCertificateFile /etc/letsencrypt/live/os-vps276.projet-okinawa.org/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/os-vps276.projet-okinawa.org/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/os-vps276.projet-okinawa.org/chain.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
You may note the web application context set to /okinawa.
My tomcat configuration is listening 8080, 8081 and 8443 tcp port.
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Connector port="8081" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
proxyName="www.projet-okinawa.ch" proxyPort="8443" scheme="https" />
<Connector port="8443"
protocol="org.apache.coyote.http11.Http11NioProtocol"
maxThreads="150"
SSLEnabled="true"
scheme="https"
secure="true"
clientAuth="false"
sslProtocol="TLS"
URIEncoding="UTF-8"
keystoreFile={keystore} keystorePass={password} />
The web application execute on Catalina localhost engine under the context /okinawa. The context was not defined by using a context descriptor but by auto deployment. The application executes correctly and it is accessible internally by using the port 8080 (by example: http://web.projet-okinawa.org/okinawa/participatewithus.html).
When accesing it through the proxy by using www.projet-okinawa.ch, I got an HTTP Status 404 - /okinawaokinawa/ exception.
I tested many different way to configure the reverse proxy but without success. I don't understand why the returning url is not backed to www.projet-okinawa.ch without the context that seem duplicated.
Any help is welcome.
I found my error by reading carefully http://httpd.apache.org/docs/current/mod/mod_proxy.html.
"If the first argument ends with a trailing /, the second argument should also end with a trailing /, and vice versa. Otherwise, the resulting requests to the backend may miss some needed slashes and do not deliver the expected results."
ProxyPass / http://web.projet-okinawa.org:8081/okinawa/
ProxyPassReverse / http://web.projet-okinawa.org:8081/okinawa/
solved my problem.

Related Links

OPENWRT : Redirect all wireless client's http/https traffic to the local webserver?
HAProxy redirect to subdomain
Gtmetrix Mimimize Redirect Chains
outlook calendar api redirection uri with vhost , not working
Redirect address when IP and port are mapped to domain
Masking an URL after redirect
How to redirect without change url?
.Search bar not storing history correctly on redirect from separate search page
301 redirect index.html to index.php and hide index.php from the url
Check redirect rules from .htaccess file
301 Redirect with limited access to site
How to create a custom expression to 301 redirect multiple html pages to a single page
URL Rewrite Module and Folder Redirects
handling URI redirect response in OAuth2 user agent flow
url redirecting + tracking
site The page isn't redirecting properly

Categories

HOME
notepad++
kentico
turing-machines
deep-learning
awk
themes
camera
vscode-extensions
entity-framework-core
carousel
pyqt4
interpolation
bookmarks
banner
nfs
character
barcode
owin
openpyxl
cmdb
endpoint
capistrano3
fileserver
topology
ag
poedit
blade
ember-cli
scriptella
maze
jackson-modules
has-and-belongs-to-many
autodesk-designautomation
python-2.6
memory-address
login-script
installshield-le
sharding
apiary.io
openproject
playframework-2.1
release
levenshtein-distance
postgresql-8.4
parser-generator
claims
http-request
avcapturedevice
knime
user-defined-fields
tf
colorbar
excel-dna
mouseleave
cpu-cache
trigger.io
universal-analytics
iotivity
flex4.6
file-uri
neon
nikeplus-api
jboss-tools
android-dateutils
dbamp
boost-serialization
themoviedb-api
mod-proxy
uncompress
dulwich
sql-server-data-tools
uvc
gamekit
mass-assignment
beatsmusic
imagefilter
tweenlite
insight.database
create.js
vsx
multitasking
ebay-lms
oocss
ui-select2
merb
pagedown
superscrollorama
usertype
isa-swizzling
workflow-services
creole
cruisecontrol.rb
dot-emacs
product-management

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile