0

I've got a single linux server running Apache/2.2.24 running both HTTP/HTTPS along with a Glassfish 3.1.2 server listening on port 8080.

Glassfish runs a single deployed application which has subfolders for separate websites, e.g.:

http://gfish:8080/rootSite
http://gfish:8080/rootSite/Site2
http://gfish:8080/rootSite/Site3
http://gfish:8080/rootSite/Site4

In the Apache vhosts.conf file all traffic to port 80 of each Virtual Host is re-written to 443 as follows:

RewriteEngine on
RewriteCond   %{SERVER_PORT}  !^443$
RewriteCond %{HTTPS} !on
RewriteRule ^(.*)$ https://www.site2.com/rootSite/Site2$1 [L,R]

In the Apache ssl.conf file each virtual host is configured to pass off to Glassfish as follows:

RedirectMatch ^/$ https://www.site2.com/rootSite/Site2$1
ProxyPass /rootSite/ http://gfish:8080/rootSite/
ProxyPassReverse /rootSite/ http://gfish:8080/rootSite/

The end result for a web-user is that when they navigate to http://www.site2.com they are redircted to HTTPS and proxied to Glassfish resulting in them seeing: https://www.site2.com/rootSite/Site2

This is the current working configuration.

The desired results is that the web-user does not see the subfolder and sees the site as: https://www.site2.com

What is the most efficient way to accomplish this given the existing configuration?

EDIT:

After some toying around it appears that some of the configuration within the ssl.conf file is unnecessary. I trimmed it down to the following:

ProxyRequests Off
<Proxy *>
  Order deny,allow
  Allow from all
</Proxy>
ProxyPass / http://gfish:8080/rootSite/Site2/
ProxyPassReverse / http://gfish:8080/rootSite/Site2/`

With this new configuration I am able to omit the /rootSite/Site2/ from the URL as desired however all CSS formatting and images are broken.

1 Answer 1

0

In the Apache vhosts.conf file I change the rewrite rule as such:

RewriteRule ^(.*)$ https://www.site2.com$1 [L,R]

In the ssl.conf file I trimmed it down to:

ProxyRequests Off

ProxyPass /rootSite/ http://gfish:8080/rootSite/
ProxyPassReverse /rootSite/ http://gfish:8080/rootSite/

This first set of Proxy statements was added because Site2 relies on CSS and Image files from the rootSite in order to render pages.

ProxyPass / http://rootSite:8080/rootSite/Site2/
ProxyPassReverse / http://rootSite:8080/rootSite/Site2/

The second set of Proxy statements hooks the external root of the website to the internal Glassfish Site2 root.

This configuration gave me the desired result of external users seeing https://www.site2.com/

THE NEW PROBLEM

I handed this configuration off to the developers for testing and it turns out that there are absolute URLs in their code which they aren't willing to change. In this case, the home page has a login form and the form action points to the absolute URL of http://www.site2.com/rootSite/site2/login.xhtml Any web-user clicking on the form submit button is then redirected to the site, again revealing the unwanted subfolders in the URL.

The solution I've been striving towards is to implement and configure mod_proxy_html.

To that end I compiled the necessary information into Apache to enable the module and then created an proxy_html.conf file with the following content:

ProxyHTMLLinks a href
ProxyHTMLLinks area href
ProxyHTMLLinks link href
ProxyHTMLLinks img src longdesc usemap
ProxyHTMLLinks object classid codebase data usemap
ProxyHTMLLinks q cite
ProxyHTMLLinks blockquote cite
ProxyHTMLLinks ins cite
ProxyHTMLLinks del cite
ProxyHTMLLinks form action
ProxyHTMLLinks input src usemap
ProxyHTMLLinks head profile
ProxyHTMLLinks base href
ProxyHTMLLinks script src for

ProxyHTMLEvents onclick ondblclick onmousedown onmouseup \
onmouseover onmousemove onmouseout onkeypress \
onkeydown onkeyup onfocus onblur onload \
onunload onsubmit onreset onselect onchange

Within the ssl.conf file I adjusted the Proxy configuration as follows:

ProxyPass /rootSite/ http://gfish:8080/rootSite/
ProxyPassReverse /rootSite/ http://gfish:8080/rootSite/

ProxyRequests Off
ProxyPass / http://gfish:8080/rootSite/Site2/
<Location />
ProxyPassReverse /
ProxyHTMLEnable On
ProxyHTMLURLMap http://gfish:8080/rootSite/Site2/ /
ProxyHTMLURLMap / /
</Location>

Unfortunately even with this in place I am not achieving the desired result of having the Form action link re-written.

Input and insight is more than welcome.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .