代理服务器_多层服务器之间的关联设置

https://www.test1.com
www.test1.com:80
www.test2.com:80
www.test2.com:8090
www.test3.com

Apache反向代理服务器的设置(第一层www.test2.com)

httpd.conf中的设置

...
#修改被访问端口号
Listen 8090
ServerName www.test2.com
...

#开启反向代理
ProxyPreserveHost On
#关闭代理
ProxyRequests Off   

#使用ProxyPass指令激活反向代理
#请求中包含/index,请求将被转发给http://www.test3.com:8081/index/
ProxyPass /index http://www.test3.com:8081/index/
#和ProxyPass指令配合使用,使Apache调整HTTP重定向应答中Location, Content-Location, URI头里的URL
ProxyPassReverse /index http://www.test3.com:8081/index/

#所有请求转发给http://www.test3.com:8080/
ProxyPass / http://www.test3.com:8080/
ProxyPassReverse / http://www.test3.com:8080/

ProxyPass /todo http://www.test3.com:8080/todo/
ProxyPassReverse /todo http://www.test3.com:8080/todo/
...

关于ProxyPreserveHost的说明:
Enabling the Apache ProxyPreserveHost directive
The ProxyPreserveHost directive is used to instruct Apache mod_proxy, when acting as a reverse proxy, to preserve and retain the original Host: header from the client browser when constructing the proxied request to send to the target server.

The default setting for this configuration directive is Off, indicating to not preserve the Host: header and instead generate a Host: header based on the target server’s hostname.

Because this is often not what is wanted, you should add the ProxyPreserveHost On directive to the Apache HTTPD configuration, either in httpd.conf or related/equivalent configuration files.


squid反向代理服务器的设置(第二层www.test2.com)

关于squid的squid.conf设置

...
http_port www.test2.com:80 accel defaultsite=www.test2.com
...

cache_peer www.test2.com parent 8090 0 no-query originserver name=index 
acl aclIndex  urlpath_regex ^(/)?index(/)?
cache_peer_access index allow aclIndex  

cache_peer www.test2.com parent 8090 0 no-query originserver name=todo
acl aclTodo urlpath_regex ^(/)?todo(/)?
cache_peer_access todo allow aclTodo 

Apache反向代理服务器的设置(第三层www.test1.com)

关于https的ssl.conf设置

<Location /index>
    ProxyPass http://www.test2.com:80/index
    ProxyPassReverse http://www.test2.com:80/index
    ProxyPassReverseCookieDomain www.test2.com www.test1.com
    SetEnvIf Referer "https://www\.test1\.com/index/" allow_ref
    SetEnvIf Referer "^$" allow_ref
    order deny,allow
    deny from all
    allow from env=allow_ref 
</Location>
<Location /todo>
    ProxyPass http://www.test2.com:80/todo
    ProxyPassReverse http://www.test2.com:80/todo
    ProxyPassReverseCookieDomain www.test2.com www.test1.com
    SetEnvIf Referer "https://www\.test1\.com/index/" allow_ref
    SetEnvIf Referer "https://www\.test1\.com/todo/" allow_ref
    SetEnvIf Referer "^$" allow_ref
    order deny,allow
    deny from all
    allow from env=allow_ref   
</Location>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值