简体   繁体   English

AWS Elastic Beanstalk Docker 未将默认的 nginx 反向代理设置为应用程序端口

[英]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.confcat /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.

相关问题 AWS Elastic Beanstalk 中 Laravel 的自定义 nginx 配置 - Custom nginx configuration for Laravel in AWS Elastic Beanstalk 使用 Nginx 容器通过 docker-compose 代理到 Elastic Beanstalk 上的 React 容器:这是一种有效的方法吗? - Using an Nginx container to proxy to a React container on Elastic Beanstalk with docker-compose: is that a valid approach? 在 AWS elastic beanstalk 上安装 nginx 模块 - Install nginx module on AWS elastic beanstalk Nginx反向代理的设置 - Setting Up of Nginx reverse proxy 在 aws elastic beanstalk 上设置 linux 服务 - Setting up linux services on aws elastic beanstalk 如何在 elastic beanstalk nginx 中禁用 nginx 代理缓冲区 - how to disable nginx proxy buffer in elastic beanstalk nginx 如何在 Tomcat AWS Elastic beanstalk (Spring Boot Application) 中修改或添加新的 Nginx 配置 - How to modify or add new Nginx configuration in Tomcat AWS Elastic beanstalk (Spring Boot Application) Flask 应用程序未在 AWS elastic beanstalk 上部署 - Flask Application is not getting deployed at AWS elastic beanstalk Docker nginx 反向代理未加载 static 文件 - Docker nginx reverse proxy not load static file 访问在 AWS Linux 上运行的 NGINX 配置中的 Elastic Beanstalk 环境属性 2 - Access Elastic Beanstalk environment properties in NGINX configs running on AWS Linux 2
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM