apache问题。一定很简单,但我失败了。
我正在尝试将apache配置为对其背后的两个服务器的反向代理。棘手的部分是注册代理规则的唯一区别是子路径。
我的想法是:
mydomain.com -> localhost:8083 mydomain.com/api -> localhost:8080/api
目前我的配置是这样的:
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
但是/ api不起作用,它不断将请求发送到8083。为什么有任何想法?
感谢您的关注
尝试在“ /”之前执行“ / api” ProxyPass + ProxyPassReverse。我强烈怀疑'/'是一个包罗万象的东西,而您永远也不会遇到'/ api'的情况。这可以解释为什么您总是选择8083,即“ /”情况。
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/