NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
xiaoz
1.03D
V2EX  ›  NGINX

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

  •  
  •   xiaoz ·
    helloxz · Jan 27, 2016 · 17539 views
    This topic created in 3785 days ago, the information mentioned may be changed or developed.

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

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

    proxy_pass 那里改成源站 HTTPS 地址即可,你是怎么配的?
    lhbc
        2
    lhbc  
       Jan 27, 2016
    站内搜索 nginx 反代 google
    Had
        3
    Had  
       Jan 27, 2016
    升级 Nginx 1.8 + 试试?
    shuson
        4
    shuson  
       Jan 27, 2016
    这俩参数好好结合官方文档检查
    proxy_pass and proxy_redirect
    liuweisj
        5
    liuweisj  
       Jan 27, 2016
    ```
    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  
       Jan 27, 2016
    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;
    }
    }
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4117 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 40ms · UTC 00:56 · PVG 08:56 · LAX 17:56 · JFK 20:56
    ♥ Do have faith in what you're doing.