首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >到HHVM的Nginx代理传递连接超时

问到HHVM的Nginx代理传递连接超时
EN

Stack Overflow用户
提问于 2016-10-19 05:27:27
回答 1查看 51关注 0票数 0

我遇到了一个非常奇怪的问题。我的服务器通过proxypass连接到我的api。

代码语言:javascript
复制
server {
    listen   80;
    server_name  www.example.com;

    location / {
        root    /data/sites/www.example.com/public_html/;
        index  index.php index.html index.htm;
        try_files $uri $uri/ /index.php?rt=$uri&$args;
    }

    location /api {
        proxy_pass_header  Set-Cookie;

        proxy_pass_header  P3P;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Fowarded-Host $host;
        proxy_set_header   X-Real-IP $remote_addr;
        port_in_redirect off;
        proxy_http_version 1.1;
        proxy_set_header Connection "";
        proxy_pass https://api.example.com/;
        proxy_connect_timeout 60;
    }

    location ~ \.php$ {
        root    /data/sites/www.example.com/public_html/;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index  index.php;
        #fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        fastcgi_param  PATH_INFO        $fastcgi_path_info;
        fastcgi_param  ENV  production;
        fastcgi_param HTTPS off;
        fastcgi_read_timeout 300;
    }

}

因此url www.example.com/api是对api.example.com的代理传递。但是连接总是超时。现在,如果我在浏览器中直接转到api.example.com,它就可以工作了!

所以我很困惑。有谁知道这是怎么回事吗?

EN

回答 1

Stack Overflow用户

发布于 2016-10-19 15:23:24

如果api.example.com是DNS名称而不是upstream标签,则可能需要添加解析器语句以授予nginx对DNS的访问权限。

代码语言:javascript
复制
resolver 8.8.8.8;
proxy_pass https://api.example.com/;

详情请参见this document。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40118376

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档