业务需求:
国外网站接口无法访问国内的服务器,通过香港服务器配置反向代理服务器解决国内国外互通访问问题
配置原理图:
apache主配置文件:
#Url Proxy
Include conf/extra/proxy-url.conf
extra目录下配置文件:
proxy-url.confproxy-url.conf
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule lbmethod_byrequests_module modules/mod_lbmethod_byrequests.so
LoadModule lbmethod_bytraffic_module modules/mod_lbmethod_bytraffic.so
LoadModule lbmethod_bybusyness_module modules/mod_lbmethod_bybusyness.so
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so
LoadModule rewrite_module modules/mod_rewrite.so
ProxyRequests Off
<Proxy balancer://mycluster>
BalancerMember http://1.1.1.1:1234
</Proxy>
<Location /manager>
SetHandler balancer-manager
Order Deny,Allow
Allow from all
</Location>
<VirtualHost *:80>
ServerAdmin webmaster@chinasoft.com
DocumentRoot "G:/uc/htdocs"
ServerName www.abc.com:80
ErrorLog "logs/abc.com-error.log"
CustomLog "logs/abc.com-access.log" common
DirectoryIndex index.html index.htm index.php default.php app.php u.php
<Directory "G:/uc/htdocs">
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
RewriteEngine on
RewriteRule ^/Upload/Product/(.*)/(.*)/(.*)/(.*\.(jpg|png|gif|bmp|tif|pcx|tga|exif|fpx))$ balancer://mycluster/Upload/Product/$1/$2/$3/$4 [P]
RewriteRule ^/Upload/Product/(.*)/(.*)/(.*)/(.*)/(.*\.(jpg|png|gif|bmp|tif|pcx|tga|exif|fpx))$ balancer://mycluster/Upload/Product/$1/$2/$3/$4/$5 [P,L]
ProxyPass /Upload balancer://mycluster
ProxyPassReverse /Upload balancer://mycluster
</VirtualHost>
最后实现的功能: