[英]Apache proxying subdomain root requests
Internal Tomcat server that has webapps listening on 8080: 具有在8080上侦听的webapp的内部Tomcat服务器:
"http://internal:8080/foo-webservice/" “ http:// internal:8080 / foo-webservice /”
"http://internal:8080/foo-website/" “ http:// internal:8080 / foo-website /”
External facing Apache server is proxying requests for a subdomain: 面向外部的Apache服务器正在代理对子域的请求:
"http://foo.domain.com/" “ http://foo.domain.com/”
Any requests of the root of the subdomain would be proxied to the foo-website webapp on Tomcat. 子域根目录的任何请求都将被代理到Tomcat上的foo-website webapp。
Any other requests would be proxied to the appropriate path / webapp 任何其他请求将被代理到适当的路径/ webapp
Request: 请求:
"http://foo.domain.com/index.html" “ http://foo.domain.com/index.html”
Proxied to: 代理至:
"http://internal:8080/foo-website/index.html" “ http:// internal:8080 / foo-website / index.html”
Request: 请求:
"http://foo.domain.com/webservice/listener.html?param1=foo¶m2=bar" “ http://foo.domain.com/webservice/listener.html?param1=foo¶m2=bar”
Proxied to: 代理至:
"http://internal:8080/foo-webservice/listener.html?param1=foo¶m2=bar" “ http:// internal:8080 / foo-webservice / listener.html?param1 = foo&param2 = bar”
Current virtual host definition which satisfies Use Case B: 满足用例B的当前虚拟主机定义:
<VirtualHost *:80> ServerName foo.domain.com ProxyRequests Off <Proxy *> Order deny,allow Allow from all </Proxy> ErrorLog /var/log/apache2/foo_error.log LogLevel warn CustomLog /var/log/apache2/foo_access.log combined # RewriteRules # ? # ProxyPass ProxyPreserveHost On ProxyPass / http://internal:8080/ ProxyPassReverse / http://internal:8080/ </VirtualHost>
# RewriteRules
RewriteEngine On
RewriteRule ^/(.*) http://internal:8080/foo-website/$1 [P]
# RewriteRules
RewriteEngine On
RewriteRule ^/$ http://internal:8080/foo-website/$1 [P]
ProxyPass rules match in order ProxyPass规则按顺序匹配
ProxyPass /webservice/ http://internal:8080/foo-webservice/
ProxyPassReverse /webservice/ http://internal:8080/foo-webservice/
ProxyPass /website/ http://internal:8080/foo-website/
ProxyPassReverse /website/ http://internal:8080/foo-website/
ProxyPass / http://internal:8080/foo-website/
ProxyPassReverse / http://internal:8080/foo-website/
No rewrite rule. 没有重写规则。 Isn't that good enough ?
这样还不够吗?
我认为您需要使用第一次尝试,但要在每个RewriteRule
指令末尾的方括号中包含QSA(查询字符串追加)标志。
I think the issue with Attempt 2 (none of the files in the js, img or css folders being mapped) was a sign that my approach was wrong. 我认为Attempt 2的问题(没有映射js,img或css文件夹中的文件)表明我的方法是错误的。
My solution now is to redirect any requests to the root, to the foo-website webapp. 我现在的解决方案是将所有请求重定向到根,即foo-website webapp。
<VirtualHost *:80> ServerName foo.domain.com ProxyRequests Off <Proxy *> Order deny,allow Allow from all </Proxy> ErrorLog /var/log/apache2/foo_error.log LogLevel warn CustomLog /var/log/apache2/foo_access.log combined # RewriteRules RewriteEngine On RewriteRule ^/$ /foo-website/ [R] # ProxyPass ProxyPreserveHost On ProxyPass / http://internal:8080/ ProxyPassReverse / http://internal:8080/ </VirtualHost>
This was not what I originally wanted, but I think this is the resolution. 这不是我最初想要的,但是我认为这是解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.