2016-10-18 3 views
0

У меня возникла очень странная проблема. У меня есть мои серверы, подключающиеся к моему api через proxypass.Время соединения прокси-сервера Nginx на время HHVM

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; 
    } 

} 

Так гиперссылка www.example.com/api является прокси-пропуском api.example.com. Но соединение всегда тайм-ауты. Теперь, если я перейду на api.example.com прямо в мой браузер, он РАБОТАЕТ!

Так что я озадачен. У кого-нибудь есть идеи, что может произойти?

ответ

0

Если api.example.com является DNS-именем, а не меткой upstream, возможно, вам придется добавить оператор resolver, чтобы предоставить nginx доступ к DNS.

resolver 8.8.8.8; 
proxy_pass https://api.example.com/; 

Для получения более подробной информации см. this document.

Смежные вопросы