V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
xiaoz
V2EX  ›  NGINX

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

  •  
  •   xiaoz ·
    helloxz · 2016-01-27 14:36:06 +08:00 · 16886 次点击
    这是一个创建于 3017 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

    第 1 条附言  ·  2016-01-27 15:41:11 +08:00
    已经可以了,配置本身没有问题,反代出现 502 ,最后发现服务器本身到源站 culr 都不能抓取,服务器本身网络问题导致,换台服务器可以了。非常感谢各位的回答。
    6 条回复    2016-01-27 15:59:25 +08:00
    qgy18
        1
    qgy18  
       2016-01-27 14:49:18 +08:00
    Nginx 不支持正向代理 HTTPS ,因为它不支持 CONNECT ,反代 HTTPS 没有任何问题啊。

    proxy_pass 那里改成源站 HTTPS 地址即可,你是怎么配的?
    lhbc
        2
    lhbc  
       2016-01-27 14:49:35 +08:00
    站内搜索 nginx 反代 google
    Had
        3
    Had  
       2016-01-27 14:51:19 +08:00
    升级 Nginx 1.8 + 试试?
    shuson
        4
    shuson  
       2016-01-27 14:53:55 +08:00
    这俩参数好好结合官方文档检查
    proxy_pass and proxy_redirect
    liuweisj
        5
    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
        6
    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;
    }
    }
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2285 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 03:35 · PVG 11:35 · LAX 20:35 · JFK 23:35
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.