- 之前某一个项目中用到的内容,比较简单但记录一下,下次用到直接抄了
- 此处以将
https://blog.mastera.in
反代至https://mastera.in/blog
为例
location / {
proxy_pass http://127.0.0.1:808;
proxy_http_version 1.1;
proxy_cache_bypass $http_upgrade;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
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 X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
}
location /blog/ {
proxy_pass https://blog.mastera.in/; #后置斜杠不能少
proxy_set_header Host blog.mastera.in;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
转载请标注来源