基于子路径反向代理两台服务器

Reverse proxy two servers based on subpath

阿帕奇问题。一定很简单,但我失败了。

我正在尝试将 apache 配置为它后面的两个服务器的反向代理。棘手的部分是注册代理规则的唯一区别是子路径。

我的想法是:

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

目前我的配置是这样的:

<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>

但是 /api 不工作,它一直向 8083 发送请求。关于原因有什么想法吗?

感谢关注

尝试在“/”之前执行“/api”ProxyPass+ProxyPassReverse。我强烈怀疑 '/' 是一个包罗万象的角色,你永远不会遇到 '/api' 的情况。这可以解释为什么你总是去 8083,这是 '/' 的情况。

<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>