3

apache question. Must be something simple, but I'm failing.

I'm trying to configure apache as a reverse proxy to two servers behind it. The tricky part is that the only difference to register the proxy rule is a subpath.

My idea is:

mydomain.com -> localhost:8083
mydomain.com/api -> localhost:8080/api

Currently my config is this:

<VirtualHost *:80>
        ProxyPreserveHost On
        ProxyRequests Off
        ServerName mydomain.com
        ServerAlias www.mydomain.com

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        ProxyPass / http://localhost:8083/
        ProxyPassReverse / http://localhost:8083/

        ProxyPass /api http://localhost:8080/api #already tried with slashes on both first and second parameters
        ProxyPassReverse /api http://localhost:8080/api #already tried with slashes on both first and second parameters

</VirtualHost>

But the /api isn't working, it keep sending the request to 8083. Any ideas on why?

thanks for the attention

1 Answer 1

6

Try doing the '/api' ProxyPass+ProxyPassReverse before the '/' one. I strongly suspect '/' is acting as a catchall and you're never getting to the '/api' case. This would explain why you always go to 8083, which is the '/' case.

<VirtualHost *:80>
        ProxyPreserveHost On
        ProxyRequests Off
        ServerName mydomain.com
        ServerAlias www.mydomain.com

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        ProxyPass /api http://localhost:8080/api #already tried with slashes on both first and second parameters
        ProxyPassReverse /api http://localhost:8080/api #already tried with slashes on both first and second parameters

        # do this last...
        ProxyPass / http://localhost:8083/
        ProxyPassReverse / http://localhost:8083/


</VirtualHost>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.