Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: How can I keep the URL unchanged after redirecting |
|
Author |
|
chenyichen
Joined: 20 Sep 2012 Posts: 3 Location: Taiwan (R.O.C.), Taipei City
|
Posted: Fri 19 Oct '12 3:30 Post subject: How can I keep the URL unchanged after redirecting |
|
|
Dear Sir,
There is one issue needing to consult:
I have set up Apache as a SSL front end for our web applications deployed in GlassFish Server 3.0.1 Open Source Edition, how can I keep the original URL displayed in the web browser address bar unchanged after redirecting via Rewrite / ProxyPass and ProxyPassReverse
Best Regards and Have a Nice Day
Chen Yi Chen
Reference 1:
RewriteEngine On
# If the request URL does not start with a slash (/), prepend it.
RewriteRule ^([^/].*)$ /$1 [E=redirect:y,N]
# If the request URL starts with more than one slash (/), keep only the first one.
RewriteRule ^//+(.*)$ /$1 [E=redirect:y,N]
# If there are more than one dot (.) in succession in the URL, replace them with just one.
RewriteRule ^(.*)\.\.+(.*)$ $1.$2 [E=redirect:y,N]
# If there are more than one slash (/) in succession in the URL, replace them with just one.
RewriteRule ^(.*)//+(.*)$ $1/$2 [E=redirect:y,N]
# Replace any ./ in the URL with just /
RewriteRule ^(.*)\./(.*)$ $1/$2 [E=redirect:y,N]
# Replace any /. in the URL with just /
RewriteRule ^(.*)/\.(.*)$ $1/$2 [E=redirect:y,N]
# If the last component in the URL is non-empty but does not contain a dot, append a slash /
RewriteRule ^(.*/[^/.]+)$ $1/ [E=redirect:y,N]
# If any of the above rules were applied, they set the environment variable redirect to y (and restart the entire chain all over again). When they reach this point, all replacements possible have already been made.
# If and only if there were any substitutions made, the environment variable will have a y in it. If so, apply the following RewriteRule.
RewriteCond %{ENV:redirect} y
# Use a single visible redirect to redirect the browser to the cleaned up URL right now.
RewriteRule ^(.*)$ $1 [R,L]
RewriteRule ^/glassfish/(.*) http://localhost:4848/common/$1 [P]
RewriteRule ^/pcmm/(.*) http://semopstest.com:8380/pcmm$1 [P]
RewriteRule (.*) https://semopstest.com:8181$1 [P]
ProxyPassReverse /glassfish/ http://localhost:4848/common/
ProxyPassReverse /pcmm/ http://semopstest.com:8380/pcmm/
ProxyPassReverse / https://semopstest.com:8181/
# ProxyPass /glassfish/ http://localhost:4848/common/
# ProxyPass /pcmm/ http://semopstest.com:8380/pcmm
# ProxyPass / https://semopstest.com:8181/
# ProxyPassReverse /glassfish/ http://localhost:4848/common/
# ProxyPassReverse /pcmm/ http://semopstest.com:8380/pcmm
# ProxyPassReverse / https://semopstest.com:8181/ |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7377 Location: Germany, Next to Hamburg
|
Posted: Mon 22 Oct '12 11:21 Post subject: |
|
|
You should use a reverse proxy instead of rewriting. And if you can use ajp instead of http protocol. for my jenkins I use this setup with mod_proxy_ajp
Code: |
<VirtualHost *:80>
ServerName jenkins
DocumentRoot "/mario/Apache22/htdocs"
<Directory "/mario/Apache22/htdocs">
Options Indexes Includes FollowSymLinks
AllowOverride All
Order Allow,Deny
Allow from all
Deny from none
</Directory>
<Location />
ProxyPass ajp://localhost:8009/
ProxyPassReverse ajp://localhost:8009/
</Location>
</virtualhost>
|
Than start the backend server, in this case only with AJP and listen only on localhost (I don't know if that works for glassfish, too this way.
Code: |
java -jar jenkins.war --httpPort=-1 --ajp13ListenAddress=127.0.0.1
|
|
|
Back to top |
|
chenyichen
Joined: 20 Sep 2012 Posts: 3 Location: Taiwan (R.O.C.), Taipei City
|
Posted: Wed 24 Oct '12 5:00 Post subject: Re: How can I keep the URL unchanged after redirecting |
|
|
Dear James Blond,
Did you mean that I can keep the original URL displayed in the web browser address bar unchanged after using ProxyPass instead of RewriteRule and using ajp instead of http protocol
Best Regards and Have a Nice Day
Chen Yi Chen |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7377 Location: Germany, Next to Hamburg
|
Posted: Wed 24 Oct '12 12:10 Post subject: Re: How can I keep the URL unchanged after redirecting |
|
|
chenyichen wrote: |
Did you mean that I can keep the original URL displayed in the web browser address bar unchanged after using ProxyPass instead of RewriteRule
|
Yey you can keep the URL that way.
chenyichen wrote: |
and using ajp instead of http protocol
|
using ajp is a "can" not a "must". I just noticed that than there are no path issues with pictures and stuff if they are not set with relative paths. Also ajp work bidirectional and keeps the connection alive not like http which is fire and forget.
I wonder a bit, since you already had the ProxyPass and ProxyPassReverse stuff below your config, but commented out. |
|
Back to top |
|
chenyichen
Joined: 20 Sep 2012 Posts: 3 Location: Taiwan (R.O.C.), Taipei City
|
|
Back to top |
|
|
|
|
|
|