2016-04-14 9 views
2

landing.example.com:10000には、うまく動作するWebサーバーがあります。これは、ポート10000を公開するDockerコンテナです。 IPアドレスは172.17.0.2です。nginxが502の悪いゲートウェイを与えるとき、Howtoはデバッグしますか?

ポート80でnginxリバースプロキシを使用し、訪問したURLに応じて別のDockerコンテナに訪問者を送ります。

server { 
    listen 80; 
    server_name landing.example.com; 

    location/{ 
     proxy_pass http://172.17.0.2:10000/; 
    } 

    access_log /landing-access.log; 
    error_log /landing-error.log info; 
} 

私はこれを行うと、私は502 Bad Gatewayを取得し、ログが

2016/04/14 16:58:16 [error] 413#413: *84 connect() 
failed (111: Connection refused) while connecting to upstream, client: 
xxx.xxx.xxx.xxx, server: landing.example.com, request: "GET/HTTP/1.1", 
upstream: "http://172.17.0.2:10000/", host: "landing.example.com" 

答えて

2

はこれを試して言う:

ここ
upstream my_server { 
    server 172.17.0.2:10000; 
} 

server { 
    listen 80; 
    server_name landing.example.com; 
    location/{ 
     proxy_pass     http://my_server; 
     proxy_set_header   Host $host; 
     proxy_set_header   X-Real-IP $remote_addr; 
     proxy_http_version   1.1; 
     proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for; 
     proxy_set_header   X-Forwarded-Proto http; 
     proxy_redirect    http:// $scheme://; 
    } 
} 

あなたは上流のサーバー(IPまたはホスト名によってサーバー)を定義 ヘッダーも転送するようにしてください。これにより、サーバーは応答するユーザーを知っています。

関連する問題