- 代理单个地址
代理单个地址,意思是通过 nginx 配置之后,nginx 这边会配置出一个特定的地址,这个地址对应被代理的网站地址。
比如,网站分享后的地址是:http://192.168.31.165:81/abc/
通过 nginx 代理后,该地址可被代理为:http://192.168.31.4:8081/a1/
配置如下:
map $http_upgrade $connection_upgrade { default upgrade; '' close; } server { listen 8081; location /a1/{ proxy_cache off; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host:$server_port; proxy_set_header X-Forwarded-For $remote_addr; proxy_pass http://192.168.31.165:81/abc/; } }
- 代理整个 Web 服务器
代理整个 Web 服务器,意思是通过 nginx 代理之后,服务器的所有站点地址,在 nginx 这边都有一个对应的地址。
比如,web服务器配置了两个服务器站点,地址分别是:
http://192.168.31.165:81/abc/
http://192.168.31.165:81/def/
通过 nginx 代理后,入口地址被代理为** http://192.168.31.4:8082/a/ **,则上面站点可分别通过以下链接进行访问:
http://192.168.31.4:8082/a/abc/
http://192.168.31.4:8082/a/def/
配置如下:
map $http_upgrade $connection_upgrade { default upgrade; '' close; } server { listen 8082; location /a/{ proxy_cache off; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host:$server_port; proxy_set_header X-Forwarded-For $remote_addr; proxy_pass http://192.168.31.165:81/; } }
标签:upgrade,http,header,代理,192.168,nginx,set,proxy,链接 From: https://www.cnblogs.com/wiggin-Z/p/17346310.html