[英]AWS Elastic Beanstalk Docker is not setting a default nginx reverse proxy to application port
I've deployed a dockerized node app to elastic beanstalk and instead of my app, the link goes to a default "Welcome to nginx on Amazon Linux."我已经将一个 dockerized 节点应用程序部署到弹性 beanstalk,而不是我的应用程序,链接转到默认的“欢迎使用亚马逊 Linux 上的 nginx”。 page saying it means the web server is installed at the site.
页面说这意味着 web 服务器已安装在站点上。
It's using Docker running on 64bit Amazon Linux 2它使用 Docker 在 64 位亚马逊上运行 Linux 2
From what I could find scouring the inte.net, the eb default nginx reverse proxy should forward to either port 8000, 8080, or 5000 (information varies).根据我搜索 inte.net 的内容,eb 默认 nginx 反向代理应该转发到端口 8000、8080 或 5000(信息各不相同)。
I've confirmed my docker app is running properly and opened all three ports to the docker container as a test to narrow later.我已经确认我的 docker 应用程序运行正常,并打开了 docker 容器的所有三个端口作为稍后缩小范围的测试。 I know that part is working fine because allowing incoming for them in the ec2 security group successfully routes to my app using the ec2 public IP ie 55.555.555.555:8080 or 55.555.555.555:5000
我知道这部分工作正常,因为允许 ec2 安全组中的他们使用 ec2 public IP 成功路由到我的应用程序,即 55.555.555.555:8080 或 55.555.555.555:5000
Related answers suggest I can find the reverse proxy port in /etc/nginx/nginx.conf
or cat /etc/nginx/conf.d/elasticbeanstalk-nginx-docker-upstream.conf
(not found) or /etc/nginx/conf.d/elasticbeanstalk/00_application.conf
(not found).相关答案建议我可以在
/etc/nginx/nginx.conf
或cat /etc/nginx/conf.d/elasticbeanstalk-nginx-docker-upstream.conf
(未找到)或/etc/nginx/conf.d/elasticbeanstalk/00_application.conf
中找到反向代理端口/etc/nginx/conf.d/elasticbeanstalk/00_application.conf
(未找到)。
Here's /etc/nginx/nginx/nginx.conf
:这是
/etc/nginx/nginx/nginx.conf
:
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 4096;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
server {
listen 80;
listen [::]:80;
server_name _;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
error_page 404 /404.html;
location = /404.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
}
I know I can add my own nginx config in.ebextensions but I'm really trying to avoid it because I don't know what I'm doing, more to maintain, and shouldn't this just work out of the box?我知道我可以在 .ebextensions 中添加我自己的 nginx 配置,但我真的想避免它,因为我不知道我在做什么,更多的是维护,这不应该开箱即用吗?
Update:更新:
I added我加了
location / {
proxy_pass http://127.0.0.1:8080;
}
to the nginx.conf server block within the ec2 container, restarted the service, and now the eb url correctly routes to my app.到 ec2 容器内的 nginx.conf 服务器块,重新启动服务,现在 eb url 正确路由到我的应用程序。
How do I avoid having to do this for every environment or using a custom nginx config?如何避免必须为每个环境执行此操作或使用自定义 nginx 配置?
Since you are using Docker running on 64bit Amazon Linux 2
should use .platform
folder to customize your nginx as shown in the docs in "Reverse proxy configuration" section.由于您使用
Docker running on 64bit Amazon Linux 2
的 Docker,因此应使用.platform
文件夹自定义您的 nginx,如“反向代理配置”部分的文档所示。
Therefore, you could have the following .platform/nginx/conf.d/myconfig.conf
with content:因此,您可以拥有以下
.platform/nginx/conf.d/myconfig.conf
内容:
location / {
proxy_pass http://127.0.0.1:8080;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.