502 错误网关 - nginx/1.16.1 - 用于部署在 AWS Elastic Beanstalk 上的破折号(绘图)应用程序 [英] 502 Bad Gateway - nginx/1.16.1 - for dash (plotly) application deployed on AWS Elastic Beanstalk

查看:116
本文介绍了502 错误网关 - nginx/1.16.1 - 用于部署在 AWS Elastic Beanstalk 上的破折号(绘图)应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 AWS Beanstalk 上部署了一个 Dash (Plotly) 应用程序,当我尝试从 AWS Beanstalk 访问环境时,我得到一个502 Bad Gateway"页面.除此之外,我在 error.log 下观察到几个failed (111: Connection denied)....."行,如下所示.

I have deployed a Dash (Plotly) application on AWS Beanstalk and when attempting to access the environment from AWS Beanstalk I get a '502 Bad Gateway' page. In addition to this, I'm observing several "failed (111: Connection refused)....." lines under the error.log as shown below.

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文件如下图:

The nginx.conf file is shown below:

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

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

Would be great if someone could suggest a fix for this issue.

推荐答案

我今天刚想出这个并通过修改位于 .ebextensions/application.config 中的文件解决:

I just came up with this today and resolved by modifying the file located in .ebextensions/application.config from:

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

到:

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

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

and then in my application.py file:

import dash

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

希望有帮助!

这篇关于502 错误网关 - nginx/1.16.1 - 用于部署在 AWS Elastic Beanstalk 上的破折号(绘图)应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆