前端https请求到A,A将该https请求转发的B
场景: 前端传过来一个https请求到A服务器的Nginx,然后A服务器将该请求以https方式转发到B服务器的Nginx
A服务器配置:
server {
listen 443;
server_name lalala1.com;
ssl on;
ssl_certificate /home/zhuhg/ssl/server.crt;
ssl_certificate_key /home/zhuhg/ssl/server.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
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_redirect http:// $scheme://;
proxy_pass http://lalala2.com;
index index.html index.htm;
}
这里的$scheme是Nginx内置变量,为进来的请求协议,在这个例子中$scheme==https