0

I am trying to route an application to a sub route on an internal server, using Gunicorn with my Django app. My virtual host file looks like this:

LoadModule proxy_module /usr/lib64/apache2/mod_proxy.so
LoadModule proxy_http_module /usr/lib64/apache2/mod_proxy_http.so
<VirtualHost *:80>
        ServerName 172.16.1.81
        <Location "/mycustomapp">
            ProxyPreserveHost On
            ProxyPass http://127.0.0.1:9090
            ProxyPassReverse http://127.0.0.1:9090
        </Location>

</VirtualHost>

When I navigate to 172.16.1.81/mycustomapp , I keep getting a 404 not found error when trying to navigate to the application on that route. Is there something else I am doing wrong here?

2
  • Your app is running on port 9090 and not on 3000 (which is the default Django port)? Commented Feb 23, 2019 at 20:14
  • Yes. Using Gunicorn, I bind it to listen on port 9090. Commented Feb 23, 2019 at 21:22

1 Answer 1

0

Okay, I figured it out. For anyone running into this type of problem in the future, the solution lies in using the ServerPath directive inside your VirtualHost configuration. So for example, if you wanted to have an application be served at 172.15.1.20/app1 and another application served at 172.15.1.20/app2 (via port forwarding to a process listening on a port) the virtual host configuration would like the following:

LoadModule proxy_module /usr/lib64/apache2/mod_proxy.so
LoadModule proxy_http_module /usr/lib64/apache2/mod_proxy_http.so
<VirtualHost *:80>
    ServerName 172.15.1.20

    ProxyPreserveHost On

    ProxyPass /app1 http://127.0.0.1:9090
    ProxyPassReverse /app1 http://127.0.0.1:9090

    ProxyPass /app2 http://127.0.0.1:9080
    ProxyPassReverse /app2 http://127.0.0.1:9080

</VirtualHost>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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