2017-07-06 16 views
0

私は、AWS Elastic Beanstalkへの単一のDockerコンテナデプロイメントを持っています。AWS Elastic Beanstalkのデプロイメント502 Gateway Error

サイトにアクセスすると、502エラーが返され、Dockerコンテナ内のポートが公開されていないと判断されます。

これらは私の設定です:

Dockerrun.aws.json:

{ 
"AWSEBDockerrunVersion": "1", 
"Volumes": [ 
    { 
    "ContainerDirectory": "/var/app", 
    "HostDirectory": "/var/app" 
    } 
], 
"Logging": "/var/eb_log", 
"Ports": [ 
    { 
    "containerPort": 80 
    } 
] 
} 

Dockerfile

FROM ubuntu:16.04 

# Install Python Setuptools 
RUN rm -fR /var/lib/apt/lists/* 
RUN apt-get update 
RUN apt-get install -y software-properties-common 
RUN add-apt-repository ppa:jonathonf/python-3.6 
RUN apt-get update && apt-get install -y python3-pip 
RUN apt-get install -y python3.6 
RUN apt-get install -y python3-dev 
RUN apt-get install -y libpq-dev 
RUN apt-get install libffi-dev 
RUN apt-get install -y git 

# Add and install Python modules 
ADD requirements.txt /src/requirements.txt 
RUN cd /src; pip3 install -r requirements.txt 

# Bundle app source 
ADD . /src 

# Expose 
EXPOSE 80 

# Run 
CMD ["python3", "/src/app.py"] 

app.py

from flask import Flask 
app = Flask(__name__) 

@app.route("/") 
def hello(): 
    return "Hello World!" 

# run the app. 
if __name__ == "__main__": 
    # Setting debug to True enables debug output. This line should be 
    # removed before deploying a production app. 
    app.debug = False 
    app.run(port=80) 

私は私のドッキングウィンドウでこれを参照してください-ps.log:

CONTAINER ID  IMAGE    COMMAND     CREATED    
STATUS    PORTS    NAMES 
ead221e6d2c6  2eb62af087be  "python3 /src/app.py" 34 minutes ago  Up 34 minutes  80/tcp    peaceful_lamport 

と:

/var/log/eb-docker/containers/eb-current-app/ead221e6d2c6-stdouterr.log 
------------------------------------- 
* Running on http://127.0.0.1:80/ (Press CTRL+C to quit) 

と、このエラー:

2017/07/06 05:57:36 [error] 15972#0: *10 connect() failed (111: Connection refused) while connecting to upstream, client: 172.5.154.225, server: , request: "GET/HTTP/1.1", upstream: "http://172.17.0.3:80/", host: "bot-platform.us-west-2.elasticbeanstalk.com" 

私が間違っているのか?

答えて

1

エラーコードを検索した後、次の解決策を試すことができると思います。あなたは弾力のあるbeanstalkのnginx設定を編集しなければならないようです。ここで、nginx.configファイルを弾力のあるbeanstalkのディレクトリ.ebextionsionsに追加します。

files: 
    "/etc/nginx/conf.d/000_my_config.conf": 
    content: | 
    upstream nodejsserver { 
     server 127.0.0.1:8081; 
     keepalive 256; 
    } 

    server { 
     listen 8080; 

     location/{ 
     proxy_pass http://nodejsserver; 
     proxy_set_header Connection ""; 
     proxy_http_version 1.1; 
     proxy_set_header  Host   $host; 
     proxy_set_header  X-Real-IP  $remote_addr; 
     proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for; 
     } 

     location /myconfig { 
     proxy_pass http://my_proxy_pass_host; 
     } 
    } 

おそらく少し調整する必要がありますが、これは問題を解決するための適切な方法と思われます。あなたのエラーをGoogleで解決するには、この問題を解決するためにnginxを調整する方法について、多少異なる解決策があります。

関連する問題