根据url转发任何求情
http求情
http://localhost/proxy/http://baidu.com/
会访问:http://baidu.com
https求情
http://localhost/proxy/https://baidu.com/
会访问:https://baidu.com
http{
#省略其他配置
resolver 8.8.8.8 ipv6=off;
server {
listen 80;
server_name localhost;
#通过正则表达式,截取指定路径
if ($request_uri ~ ^/proxy/(.*))
{
set $backend_host $1;
}
location ^~ /proxy/ {
proxy_pass $backend_host;
#proxy_set_header Host $Host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
标签:baidu,set,http,header,Nginx,proxy,转发,动态,com
From: https://www.cnblogs.com/namejmj/p/17084147.html