首页 > 代码库 > 反向代理配置

反向代理配置

nginx

server {
    listen       80;
    server_name  localhost;

    root  /apps/web/;
    index index.html;


    location / {
    }

    location /server {
       proxy_pass http://192.168.10.73:8080/manager-webapp/;
       proxy_cookie_path /manager-webapp/  /server/;
    }

    location /client  {
       proxy_pass http://192.168.10.23:8080/api-webapp/;
       proxy_cookie_path /api-webapp/  /client/;
    }
}

  多服务器应用接口配置。其中proxy_cookie_path用于设置cookie有效性访问URI的转换,从nginx1.1.15开始支持。

 

Apache

<VirtualHost *:8084>
    DocumentRoot "D:\code\web"
    ProxyPreserveHost On
    #ProxyPass /server/ http://localhost:12306/
    #ProxyPassReverse /server/ http://localhost:12306/

    ProxyPass /server/ http://192.168.20.112:8080/
    ProxyPassReverse /server/ http://192.168.20.112:8080/
    #上传应用配置
    ProxyPass /client/  http://192.168.10.23:8080/api-webapp/
    ProxyPassReverse /client/  http://192.168.10.23:8080/api-webapp/
    ProxyPassReverseCookiePath /manager-webapp /
</VirtualHost>

        其中,ProxyPassReverseCookiePath用于转换cookie的uri。否则可能造成服务器无法访问到session。