2016-04-28 36 views
2

私は光沢のあるサーバーを使ってポート3838でWebアプリケーションを構築しています。私は私のサーバー上でnginxのを停止し、ドッキングウィンドウのnginxのを使用しようとする。しかし、私は、サイトが「502-悪いゲートウェイ」はエラーとnginxのログショーに来る見つける:私は、このコマンドでドッカ - nginxのインストールドッカーのnginx接続が拒否されました

2016/04/28 18:51:15 [error] 8#8: *1 connect() failed (111: Connection refused) while connecting to upstream, ... 

sudo docker pull nginx 

マイドッキングウィンドウのコマンドラインは、(明確にするために、私はいくつかのインデントを追加)のようなものです:私は私のホームディレクトリにフォルダ名「ドッキングウィンドウ-nginxの」を作成

sudo docker run --name docker-nginx -p 80:80 
    -v ~/docker-nginx/default.conf:/etc/nginx/conf.d/default.conf 
    -v /usr/share/nginx/html:/usr/share/nginx/html nginx 

、私のnginxのconfに移動しこのフォルダにファイルを作成し、次にremo私の元のconfのetc/nginx dirの場合に備えて。

私のnginxのconfファイルは、次のようになります

server { 
    listen 80 default_server; 
    # listen [::]:80 default_server ipv6only=on; 

    root /usr/share/nginx/html; 
    index index.html index.htm; 

    # Make site accessible from http://localhost/ 
    server_name localhost; 

    location/{ 
      proxy_pass http://127.0.0.1:3838/; 
      proxy_redirect http://127.0.0.1:3838/ $scheme://$host/; 
      auth_basic "Username and Password are required"; 
      auth_basic_user_file /etc/nginx/.htpasswd; 
      # enhance the performance 
      proxy_http_version 1.1; 
      proxy_set_header Upgrade $http_upgrade; 
      proxy_set_header Connection "upgrade"; 
      proxy_set_header Host $host; 
    } 
} 

答えて

3

あなたはupstremディレクティブを定義する必要があります。現在のところ、あなたのnginxはあなたのWebアプリケーションにプロキシできません。

http://nginx.org/en/docs/http/ngx_http_upstream_module.html

upstream backend { 
    server backend1.example.com  weight=5; 
    server backend2.example.com:8080; 
    server unix:/tmp/backend3; 

    server backup1.example.com:8080 backup; 
    server backup2.example.com:8080 backup; 
} 

server { 
    location/{ 
     proxy_pass http://backend; 
    } 
} 
関連する問題