用户-----( https)-----nginx_a
nginx_a-----( http)-----nginx_b
nginx_b-----( https)-----服务器
这样看的话比较清楚:
1. ( https)-----nginx_a-----( http)
2. ( http)-----nginx_b-----( https)
假设:
用户访问的地址是:
https://a.nginx.orgnginx_b 的地址是:
http://b.nginx.org服务器的地址是:
server.orgnginx_a 做升级代理,需要证书
```
server {
listen 443 ssl;
listen [::]:443 ssl;
ssl_certificate cert.pem;
ssl_certificate_key key.pem;
ssl_client_certificate ca.cer;
ssl_verify_client optional;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
server_name
a.nginx.org;
root /var/www/
a.nginx.org;
index index.html;
location = / {
proxy_pass
http://b.nginx.org:80;
proxy_set_header Host $http_host;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
}
```
nginx_b 做降级代理,不需要证书
```
server {
listen 80;
listen [::]:80;
server_name
b.nginx.org;
root /var/www/
b.nginx.org;
index index.html;
location = / {
proxy_pass
http://server.org:443;
proxy_set_header Host $http_host;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
}
```
其实这个完全可以一次代理完成,用两次代理是需要劫持流量?