前排提醒

中转使用CDN的网站,比如CF,需要增加2行代码

参考:https://www.blueskyxn.com/202101/3426.html

参考配置代码

本地中转

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

需要修改端口55555和路径/abc

远程中转HTTPS

 

location /abc {
        proxy_pass https://xxx.com/abc;
        proxy_set_header Host xxx.com:443;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-Proto https;
}

需要修改路径/abc,网址 xxx.com

 

远程中转HTTP

 

location /abc {
        proxy_pass http://xxx.com/abc;
        proxy_set_header Host xxx.com:80;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-Proto http;
}

需要修改路径/abc,网址 xxx.com

其他人的代码

 

location /YOUR_PATH {
        proxy_redirect off;
        proxy_pass http://127.0.0.1:YOUR_LOCAL_PORT;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /YOUR_ANOTHER_PATH {
        proxy_pass https://YOUR_REMOTE_DOMAIN/YOUR_ANOTHER_PATH;
        proxy_set_header Host YOUR_REMOTE_DOMAIN:443;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-Proto https;
}

点击数:303