kob*_*ame 9 apache-http-server reverse-proxy
为下一个 Apache 的reverse-proxy
问题寻求帮助。
DocumentRoot
要求:
appX
(在 xxxx:8000 上)应该通过http://aaaa/appX/ 访问appY
(在 yyyy:8000 上)为http://aaaa/appY/DocumentRoot
)应该像通常那样由 apache 提供服务defapp
-其他一切都应该代理到 aaaa:8000很容易配置appX
和appY
喜欢下一个:
ProxyPass /appX/ http://x.x.x.x:8000/
ProxyPassReverse /appX/ http://x.x.x.x:8000/
ProxyPass /appY/ http://y.y.y.y:8000/
ProxyPassReverse /appY/ http://y.y.y.y:8000/
Run Code Online (Sandbox Code Playgroud)
以上工作正常。因此,当试图访问http://localhost/appX/
接到了一个响应appX
的x.x.x.x:8000
。
但是default destinaton
for有问题everything other
。尝试添加时:
ProxyPass / http://127.0.0.1:8000/
ProxyPassReverse / http://127.0.0.1:8000/
Run Code Online (Sandbox Code Playgroud)
它不像我希望的那样工作......
有了上面的内容,想告诉 apache -其他不是/appX/
或/appY/
发送到的所有内容0:8000
。
这是遗憾的是不工作的,在defapp
什么上运行0:8000
了该请求appX
,并appY
,并为静态页面太请求。
切换定义的顺序,所以
#define first the "default destination"
ProxyPass / http://127.0.0.1:8000/
ProxyPassReverse / http://127.0.0.1:8000/
#and after the appX and appY
ProxyPass /appX/ http://x.x.x.x:8000/
ProxyPassReverse /appX/ http://x.x.x.x:8000/
ProxyPass /appY/ http://y.y.y.y:8000/
ProxyPassReverse /appY/ http://y.y.y.y:8000/
Run Code Online (Sandbox Code Playgroud)
也不起作用。一切都被代理到localhost:8000
.
所以,问题是:是否可以将 Apache 配置为反向代理来处理上述定义的需求?
将您的 ProxyPass 引用包装在一个<VirtualHost>
定义中,如下所示:
<VirtualHost *:*>
ProxyPreserveHost On
ProxyPass / http://192.168.111.2/
ProxyPassReverse / http://192.168.111.2/
ServerName hostname.example.com
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
使用您想要的 ServerNames 创建两个单独的一个,然后另一个没有 ServerName 或定义的代理选项(只是DocumentRoot
)。把那个放在最后。
更多信息在这里。
归档时间: |
|
查看次数: |
57857 次 |
最近记录: |