nginx 转发 反向代理 反代 的两种写法a

写法一

upstream test1 {
server 127.0.0.1:8090;
}

location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
proxy_pass http://test1;
}

写法二

location / {
proxy_pass http://127.0.0.1:8090;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
}

posted @ 2021-05-27 00:04  xfbx  阅读(522)  评论(0编辑  收藏  举报