请教一个 nginx 反向代理 https 的问题?

2016-01-27 14:36:06 +08:00
 xiaoz

使用 nginx 反向代理 http 的网站没有问题,但是去反向代理 https 的网站老是有问题,如:源站: https://www.abc.com ,然后用 https://www.123.com 去反向代理源站就会出问题,能不能给出一份 nginx 反代 https 的配置文件?

16899 次点击
所在节点    NGINX
6 条回复
qgy18
2016-01-27 14:49:18 +08:00
Nginx 不支持正向代理 HTTPS ,因为它不支持 CONNECT ,反代 HTTPS 没有任何问题啊。

proxy_pass 那里改成源站 HTTPS 地址即可,你是怎么配的?
lhbc
2016-01-27 14:49:35 +08:00
站内搜索 nginx 反代 google
Had
2016-01-27 14:51:19 +08:00
升级 Nginx 1.8 + 试试?
shuson
2016-01-27 14:53:55 +08:00
这俩参数好好结合官方文档检查
proxy_pass and proxy_redirect
liuweisj
2016-01-27 15:30:20 +08:00
```
server{
listen 443;
server_name api.weixin.qq.com;
access_log logs/weixin.qq.access.log;
error_log logs/weixin.qq.error.log;
ssl on;
ssl_certificate /usr/local/nginx/conf/server.crt;
ssl_certificate_key /usr/local/nginx/conf/server.nopass.key;
location / {
index index.html;
proxy_pass https://api.weixin.qq.com;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-proto https;
}

}
```
dofy
2016-01-27 15:59:25 +08:00
server {
listen 80;
listen 443 ssl;
server_name api.seven.org;
access_log off;

ssl_certificate /Users/Seven/works/cert/ssl-bundle.crt;
ssl_certificate_key /Users/Seven/works/cert/private.key;

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;

if ($scheme ~* "http") {
proxy_pass http://localhost:11080;
}
if ($scheme ~* "https") {
proxy_pass http://localhost:11443;
}
proxy_redirect off;
}
}

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/253715

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX