大家好,感谢你们看我的帖子!:)
我的问题
我正在尝试为一个服务器设置反向代理,该服务器监听两个不同上下文根的多个端口。仅允许来自特定 IP 地址的连接。
问题
我认为我有一个配置,但想就下面的代码寻求一些建议。它真的能工作吗?这是最好的方法吗?
<VirtualHost *:80
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<IfModule mod_proxy.c>
ProxyRequests Off
<Location /BIPortal>
ServerName external.host
ProxyPass /BIPortal http://internal.host/BIPortal
ProxyPassReverse /BIPortal http://internal.host/BIPortal
Order Deny,Allow
Deny from all
Allow from randomip
Allow from randomip
Allow from randomip
</Location>
<Location /BIViwer>
ServerName external.host
ProxyPass /BIPortal http://internal.host/BIPortal
ProxyPassReverse /BIPortal http://internal.host/BIPortal
Order Deny,Allow
Deny from all
Allow from randomip
Allow from randomip
Allow from randomip
</Location
<VirtualHost *:8080
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<IfModule mod_proxy.c>
ProxyRequests Off
<Location /BIPortal>
ServerName external.host
ProxyPass /BIPortal http://internal.host/BIPortal
ProxyPassReverse /BIPortal http://internal.host/BIPortal
Order Deny,Allow
Deny from all
Allow from randomip
Allow from randomip
Allow from randomip
</Location>
<Location /BIViwer>
ServerName external.host
ProxyPass /BIPortal http://internal.host/BIPortal
ProxyPassReverse /BIPortal http://internal.host/BIPortal
Order Deny,Allow
Deny from all
Allow from randomip
Allow from randomip
Allow from randomip
</Location
以上是您 @Romeo Ninov 的做法吗?
答案1
apache 的配置看起来应该是这样的:
<VirtualHost *:80
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<IfModule mod_proxy.c>
ProxyRequests Off
<Location /BIPortal>
ServerName external.host
ProxyPass /BIPortal http://internal.host/BIPortal
ProxyPassReverse /BIPortal http://internal.host/BIPortal
Order Deny,Allow
Deny from all
Allow from randomip
Allow from randomip
Allow from randomip
</Location>
此配置的目的是让 apache 充当内部主机的代理。我将 apache 的主机external.host
和应用程序运行的主机命名为internal.host
相同的配置应该适用于端口 8080
答案2
因此,根据 Romeo 的输入,以下答案是我为相关客户端输入的 /etc/httpd/conf.d/。我将更改一些服务器名称和 IP,但我相信在 Romeo 的帮助下,我会做得很好。我将在接下来的几天内对此进行测试,然后从那里开始,非常感谢 Romeo :)
<VirtualHost *:80
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<IfModule mod_proxy.c>
ProxyRequests Off
<Location /BIPortal>
ServerName external.host
ProxyPass /BIPortal http://internal.host/BIPortal
ProxyPassReverse /BIPortal http://internal.host/BIPortal
Order Deny,Allow
Deny from all
Allow from randomip
Allow from randomip
Allow from randomip
</Location>
<Location /BIViwer>
ServerName external.host
ProxyPass /BIViwer http://internal.host/BIViwer
ProxyPassReverse /BIViwer http://internal.host/BIViwer
Order Deny,Allow
Deny from all
Allow from randomip
Allow from randomip
Allow from randomip
</Location
<VirtualHost *:8080
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<IfModule mod_proxy.c>
ProxyRequests Off
<Location /BIPortal>
ServerName external.host
ProxyPass /BIPortal http://internal.host/BIPortal
ProxyPassReverse /BIPortal http://internal.host/BIPortal
Order Deny,Allow
Deny from all
Allow from randomip
Allow from randomip
Allow from randomip
</Location>
<Location /BIViwer>
ServerName external.host
ProxyPass /BIViwer http://internal.host/BIViwer
ProxyPassReverse /BIViwer http://internal.host/BIViwer
Order Deny,Allow
Deny from all
Allow from randomip
Allow from randomip
Allow from randomip
</Location