1

I am facing an issue with the ProxyPass on my Apache server on Ubuntu. I have configured Apache to deal with Virtual Hosts on my server. There is an application with runs on the server and uses ports 8001 8002. I need to do something like www.example.com/demo/origin to display the contents that I would see when I visit www.example.com:8000. The contents to be displayed are a host of HTML pages.

This is the section of the virtual host config that has issues

ProxyPass /demo/vader http://www.example.com:8001/  
ProxyPassReverse /demo/vader http://www.example:8001/  

ProxyPass /demo/skywalker http://www.example.com:8002/  
ProxyPassReverse /demo/skywalker http://www.example.com:8002/

Now when I visit example.com/demo/skywalker, I see the first page of port 8002, say the login.html page.

The second should have been www.example.com/demo/skywalker/userAction.html, instead the server shows www.example.com:8000/login.html. In the error logs I see something like:

[Mon Nov 11 18:01:20 2013] [debug] mod_proxy_http.c(1850): proxy: HTTP: FILE NOT FOUND /htdocs/js/demo.72fbff3c9a97f15a4fff28e19b0de909.min.js  

I do not have any folder htdocs in the system.

This is only an issue while viewing .html pages. Otherwise, no such issue occurs.

When I visit localhost:8001 it will show any and all contents without any errors or issues.

www.example.com/demo/skywalker displays a separate webpage

www.example.com/demo/origin displays a different webpage

and

www.example.com/demo/vader displays a different webpage.

I have also tried to use one more type of combination,

<Location /demo/origin/>
  ProxyPass http://localhost:8000/
  ProxyPassReverse http://localhost:8000/
  ProxyHTMLURLMap http://localhost:8000/ /
</Location>

This fails as well.

I would greatly appreciate if anyone can help me resolve this issue.

Giacomo1968
  • 3,522
  • 25
  • 38
Vijit Jain
  • 86
  • 3
  • 15

1 Answers1

0

So as far as Apache reeves prosing goes, do you have these settings in place as well?

# Proxy specific settings
ProxyRequests Off
ProxyPreserveHost On

The reason I ask is that the error is based on a JavaScript file not loading. And CORS will not allow JavaScript to load content from the same domain. And ProxyPreserveHost would preserve example.com when making a request to www.example.com:8001 or www.example.com:8002

EDIT: Going to attempt a more specific example. I suggest you redo your proxy logic & try this.

# Settings for adding a trailing slash to the URL
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/(demo)$
RewriteRule ^(.*)$ http://%{HTTP_HOST}$1/ [R=301,L]

# Settings for Apache Reverse Proxying
<IfModule mod_proxy.c>

  # Proxy specific settings
  ProxyRequests Off
  ProxyPreserveHost On

  <Proxy *>
    AddDefaultCharset off
    Order deny,allow
    Allow from all
  </Proxy>

  ProxyPass /demo/vader http://www.example.com:8001/  
  ProxyPassReverse /demo/vader http://www.example:8001/  

  ProxyPass /demo/skywalker http://www.example.com:8002/  
  ProxyPassReverse /demo/skywalker http://www.example.com:8002/

</IfModule>
Giacomo1968
  • 3,522
  • 25
  • 38
  • Thanks for that tip. i now have that in my Virtual Host configuration. however, now, when i visit https://www.example.com/demo/vader/, it takes me to http://hello.example.com/login – Vijit Jain Nov 13 '13 at 01:13
  • hello.example.com is another virtual host that is currently ran on the same apache server. – Vijit Jain Nov 13 '13 at 01:14
  • i now can redirect my https://www.example.com/demo/origin/ to www.example.com:8001/login.html, however, the URL in the browser changes as well....is there a way in which i can keep the Browser URL to https://www.example.com/demo/origin/login.html and still make the server work? – Vijit Jain Nov 13 '13 at 01:23
  • this is what i added to my virtual host configuration ` ProxyPass http://www.example.com:8001/ ProxyPassReverse / ` – Vijit Jain Nov 13 '13 at 01:24
  • Added edits with a more specific example. – Giacomo1968 Nov 13 '13 at 03:35