map $scheme $online_proxy_www {
default 39.156.66.10;
}
proxy_pass $scheme://$online_proxy_www:$server_port;
upstream online_proxy_www {
server 39.156.66.10:80;
}
upstream online_proxy_www_https {
server 39.156.66.10:443;
}
proxy_pass $scheme://online_proxy_www;
if ( $scheme = https) {
proxy_pass $scheme://online_proxy_www_https;
}
upstream online_proxy_www {
server 39.156.66.10:80;39.156.66.10
server 39.156.66.10:443 backup;
}
proxy_pass $scheme://online_proxy_www;
==========================
nginx.conf示例
upstream online_proxy_www {
server 39.156.66.10:80;
#server 39.156.66.10:443 backup;
}
upstream online_proxy_www_https {
server 39.156.66.10:443;
}
server
{
listen 80;
listen 443 ssl;
server_name blog.c1gstudio.com;
index index.html index.htm index.php;
root /opt/htdocs/www;
access_log /var/log/nginx/blog.c1gstudio.com.log access ;
include ssl.conf;
location /
{
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxypass_forwarded_for;
proxy_pass $scheme://$online_proxy_www:$server_port;
add_header X-Cache C1GPROXY1;
}
}
The post nginx自适应https的反向代理 first appeared on C1G军火库.