server { listen 443; server_name mail.jb51.net; ssl on; ssl_certificate server.crt; ssl_certificate_key server.key; location / { proxy_pass https://192.168.0.2:443; proxy_set_header Host $host:443; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Via "nginx"; } } 其中192.168.0.2是你的https主机 如果后端https没有证书的话,可以如此简化: 复制代码 代码如下: server { listen 80; server_name svn.jb51.net; location / { proxy_pass https://192.168.0.2:443; proxy_set_header Host $host:443; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Via "nginx"; proxy_set_header X-Forwarded-Proto https; #注意看这里 多了一行 } } 如果提示“SSL 接收到一个超出最大准许长度的记录。” 错误代码“ssl_error_rx_record_too_long”说明少了“ssl on;”这一行 (责任编辑:IT) |