[英]apache reverse proxy configuration
I am trying to configure reverse proxy for one application. 我正在尝试为一个应用程序配置反向代理。 Am using apache 2.2 web server below are my configuration rules 我正在使用apache 2.2 Web服务器是我的配置规则
ProxyRequests off 代理请求关闭
ProxyPreserveHost on ProxyPreserveHost在
ProxyPass /app/ ( http://11.11.111.11:123/ ) ProxyPass / app /(http://11.11.111.11:123/ )
ProxyPassReverse /app/ http://11.11.111.11:123/ ProxyPassReverse / app / http://11.11.111.11:123/
Problem: When i hit the url of my local server like myserver.co.in/app/ first page is coming (application log in page). 问题:当我点击本地服务器的URL,例如myserver.co.in/app/时,第一页即将出现(应用程序登录页面)。 after that application is redirecting to url myserver.co.in/home/index.html and redirection failed. 该应用程序重定向到URL myserver.co.in/home/index.html之后,重定向失败。 since "/app/" part is missing in the url. 因为网址中缺少“ / app /”部分。
Can any one help me to fix this issue. 任何人都可以帮助我解决此问题。 thanks in advance. 提前致谢。
because apache dosnt know you want a different page, you need to set working directory for this virtual host to the directory where you app is. 因为apache dosnt知道您想要一个不同的页面,所以需要将此虚拟主机的工作目录设置为应用程序所在的目录。
For example, 例如,
DocumentRoot "/www/example2"
so using your config would be 所以使用您的配置将是
<VirtualHost *:80>
DocumentRoot "/www/example2"
ProxyRequests off
ProxyPreserveHost on
ProxyPass /app/ (http://11.11.111.11:123/)
ProxyPassReverse /app/ http://11.11.111.11:123/
# Other directives here
</VirtualHost>
You can either modify your app to add the /app
prefix or use mod_proxy_html
. 您可以修改您的应用程序以添加/app
前缀,也可以使用mod_proxy_html
。
The following is quoted from " When ProxyPass and ProxyPassReverse aren't enough " and is modified to suite what you've asked. 以下内容引用自“ 当ProxyPass和ProxyPassReverse还不够时 ”,并进行了修改以适合您的要求。
In a nutshell, mod_proxy_html
allows you to rewrite html, javascript & css so that the URLs can cleanly go through your reverse proxy. 简而言之, mod_proxy_html
允许您重写html,javascript和css,以便URL可以清晰地通过反向代理。 This means that the backend application responds with 这意味着后端应用程序响应
<script src="/script/application.js" type="text/javascript"></script>
mod_proxy_html will converted it to mod_proxy_html会将其转换为
<script src="/app/script/application.js" type="text/javascript"></script>
To get this to work, add the following to httpd.conf 要使其正常工作,请将以下内容添加到httpd.conf中
ProxyPass /app/ (http://11.11.111.11:123/)
ProxyPassReverse /app/ http://11.11.111.11:123/
ProxyHTMLURLMap http://11.11.111.11:123/ /app/
<Location /app/>
ProxyHTMLEnable On
ProxyPassReverse http://11.11.111.11:123/
SetOutputFilter proxy-html
ProxyHTMLURLMap / /app/
ProxyHTMLURLMap /app /app
</Location>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.