0

I am using Ubuntu-15.10 wily, Apache-2.4.12

I've been trying to use ProxyPass in an SSL enabled VirtualHost like so:

ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
    Require all granted
</Proxy>
ProxyPass /myapp/ http://127.0.0.1:8090/
ProxyPassReverse /myapp/ http://127.0.0.1:8090/

With above configuration, I assumed that whatever is being served by the server on that port, e.g. web will be appended to https://www.example.com/myapp/web.

However, this is not what I get. In Apache logs I get:

... File does not exist: /var/www/html/web, referer: https://www.example.com/myapp/

Is this because I don't understand what ProxyPass is supposed to do? Or is there something wrong with my configuration that I need to correct?

ADDENDUM (18 Feb 2016)

I have turned on logging for mod_proxy and I see the following which doesn't make sense:

... connecting http://127.0.0.1:8090/ to 127.0.0.1:8090
... connected / to 127.0.0.1:8090
... fam 2 socket created to 127.0.0.1
... connection established with 127.0.0.1:8090 (127.0.0.1)
... connection complete to 127.0.0.1:8090 (127.0.0.1)
... http: has released connection for (127.0.0.1)
... proxy: connection shutdown

I am assuming that one of the addresses in the first line is the intrnal placeholder and the other is the URL being retrieved. But why in the second line the retrieved url gets connected to / instead of /myapp/ as per ProxyPass?

  • And the third alternative is that your reverse proxy is configured correctly but that it is http://127.0.0.1:8090/web that doesn't display the correct content and returns a 404... – HBruijn Feb 17 '16 at 10:10
  • I have tried to reach the server with the local IP, and it works fine. I know that the server is properly working since it is on the root of the URL, so it is the one returning the web part. – ismail Feb 17 '16 at 10:32
0

I found a solution, but it is not what I hoped for nor what I expected from my readings on ProxyPass. It might be a mistake on my part, or the documentation is not as clear as it should be. ProxyPass can not append proxied URL to a path of an invented name. So, I had to make my application load from a directory on the designated port rather than from the root of the URL as such:

ProxyPass /myapp http://127.0.0.1:8090/myapp
ProxyPassReverse /myapp http://127.0.0.1/myapp

Furthermore, A RewriteRule must be used as well if there are resources that need to be loaded, e.g. queries, images, scripts, etc.

The Rewrite rules would be:

RewriteEngine On
RewriteRule ^(.*) http://0.0.0.0:8090/$1 [P,L]

I feel like there are many other solution that might involve other proxy modules and possibly RewriteRule, however, this is the one that is as simple as my knowledge in apache got.

So, the bottom-line, at least the first component of the path must be present on both ends in order for ProxyPass to do it's job. I can not use ProxyPath to load on a path I make up without further complications in proxy settings.

I hope someone finds this answer of help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.