【问题标题】:502 Bad Gateway - nginx/1.16.1 - for dash (plotly) application deployed on AWS Elastic Beanstalk502 Bad Gateway - nginx/1.16.1 - 用于部署在 AWS Elastic Beanstalk 上的 dash (plotly) 应用程序
【发布时间】:2020-10-01 10:33:43
【问题描述】:

我在 AWS Beanstalk 上部署了 Dash (Plotly) 应用程序,当尝试从 AWS Beanstalk 访问环境时,我得到一个“502 Bad Gateway”页面。除此之外,我还在error.log下观察到几个“失败(111:连接被拒绝).....”行,如下所示。

var/log/nginx/error.log
----------------------------------------
2020/06/10 18:25:03 [error] 3863#0: *75 connect() failed (111: Connection refused) while connecting to upstream, client: 125.54.130.115, server: , request: "GET /?XDEBUG_SESSION_START=phpstorm HTTP/1.1", upstream: "http://127.0.0.1:8000/?XDEBUG_SESSION_START=phpstorm", host: "15.106.221.125:80"
2020/06/10 18:42:24 [error] 3863#0: *77 connect() failed (111: Connection refused) while connecting to upstream, client: 125.54.130.115, server: , request: "GET /index.php?s=/Index/\think\app/invokefunction&function=call_user_func_array&vars[0]=md5&vars[1][]=HelloThinkPHP HTTP/1.1", upstream: "http://127.0.0.1:8000/index.php?s=/Index/\think\app/invokefunction&function=call_user_func_array&vars[0]=md5&vars[1][]=HelloThinkPHP", host: "15.106.221.125:80"
2020/06/10 18:55:34 [error] 3863#0: *79 connect() failed (111: Connection refused) while connecting to upstream, client: 71.6.232.9, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8000/", host: "15.106.221.125"..............
....................................

nginx.conf文件如下图所示:

#Elastic Beanstalk Nginx Configuration File

usernginx;
error_log/var/log/nginx/error.log warn;
pid/var/run/nginx.pid;
worker_processesauto;
worker_rlimit_nofile    32145;

events {
    worker_connections  1024;
}

http {
    include/etc/nginx/mime.types;
    default_type  application/octet-stream;

log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

includeconf.d/*.conf;

map $http_upgrade $connection_upgrade {
default     "upgrade";
    }

server {
listen80 default_server;
access_log    /var/log/nginx/access.log main;

client_header_timeout 60;
client_body_timeout   60;
keepalive_timeout     60;
gzipoff;
gzip_comp_level4;
gzip_types text/plain text/css application/json application/javascript applic
ation/x-javascript text/xml application/xml application/xml+rss text/javascript;

# Include the Elastic Beanstalk generated locations
include conf.d/elasticbeanstalk/*.conf;
}
}

如果有人可以建议解决此问题,那就太好了。

【问题讨论】:

    标签: amazon-web-services nginx amazon-elastic-beanstalk plotly-dash


    【解决方案1】:

    我今天才想出这个问题,并通过修改 .ebextensions/application.config 中的文件来解决:

    option_settings:   
      aws:elasticbeanstalk:container:python:
        WSGIPath: application:app
    

    到:

    option_settings:   
      aws:elasticbeanstalk:container:python:
        WSGIPath: application:server
    

    然后在我的 application.py 文件中:

    import dash
    
    app = Dash(__name__)
    server = app.server
    ...
    

    希望对你有帮助!

    【讨论】:

      猜你喜欢
      • 2021-03-07
      • 2021-06-22
      • 2019-10-17
      • 2016-12-20
      • 2021-10-02
      • 2016-02-27
      • 2018-12-30
      • 2014-05-12
      • 2015-06-29
      相关资源
      最近更新 更多