【问题标题】:Why isn't AWS elastic beanstalk copying my nginx custom configuration?为什么 AWS elastic beanstalk 不复制我的 nginx 自定义配置?
【发布时间】:2020-12-01 05:07:20
【问题描述】:

我在配置弹性 beanstalk 以在 Linux 环境中运行 2 个 asp.net 核心 API 时遇到一些问题。我要做的是部署一个名为 audit 的服务,该服务在端口 5005 上运行,而一个名为 idp 的服务在端口 5000 上运行。

发生的情况是我可以访问 idp API,但不能访问审计 API。

这是我的 zip 上传的样子:

审计/**
idp/**
.platform/ngnix/conf.d/elasticbeanstalk/01_custom.conf
档案 01_cusom.conf 包含:

location /audit{
     proxy_pass          http://127.0.0.1:5005 ;
     proxy_http_version  1.1;

     proxy_set_header   Upgrade $http_upgrade;
     proxy_set_header   Connection $http_connection;
     proxy_set_header   Host $host;
     proxy_cache_bypass $http_upgrade;
     proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
     proxy_set_header   X-Forwarded-Proto $scheme;
}

location /idp{
     proxy_pass          http://127.0.0.1:5000 ;
     proxy_http_version  1.1;

     proxy_set_header   Upgrade $http_upgrade;
     proxy_set_header   Connection $http_connection;
     proxy_set_header   Host $host;
     proxy_cache_bypass $http_upgrade;
     proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
     proxy_set_header   X-Forwarded-Proto $scheme;
}

Procfile 包含:

audit: dotnet audit/audit.dll
idp: dotnet idp/idp.dll

audit 和 idp 包含我的每个应用程序的 dll。

根据文档,应该发生的情况是 .platform/ngnix/conf.d/elasticbeanstalk/01_custom.conf 中设置的配置应该在机器上的 nginx 中设置。这实际上并没有发生。我已经连接机器,发现机器上只存在一个默认配置的文件。

为了确保这是我从 /etc/nginx/conf.d/elasticbeanstalk/00_application_conf 中部署的 zip (.platform/ngnix/conf.d/elasticbeanstalk/01_custom.conf) 添加的问题,然后重新启动了 nginx服务器。这实际上解决了我的问题。

所以问题似乎是部署机制没有按文档说明工作。 (https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/dotnet-linux-platform-nginx.html)

有人对此有解决方案吗?

编辑

我尝试将 01_custom.conf 放在以下位置,但似乎不起作用:

  • .platform/ngnix/conf.d/elasticbeanstalk/
  • .platform/ngnix/conf.d/
  • .platform/ngnix 与文件 01_custom.conf
  • .platform/ngnix 与文件 nginx.conf 文件,希望覆盖 /etc/nginx/nginx.conf 中的文件

【问题讨论】:

  • 您确定您使用的是基于 Amazon Linux 2 的 EB,而不是 Amazon Linux 1。另外,如果您暴露了第二个端口,您是否为此调整了安全组?

标签: amazon-web-services asp.net-core amazon-elastic-beanstalk


【解决方案1】:

您应该放置自定义 nginx 脚本的文件夹位于 .platform/nginx/conf.d/

不要放在 elasticbeanstalk/01_custom.conf 中

https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/platforms-linux-extend.html

【讨论】:

  • 我已经尝试了多种变体,尝试将其放入 .platform/ngnix/conf.d/ 也尝试将其放入 .platform/ngnix 似乎不起作用。
  • 可能是/idp的端口。这是nginx默认配置的5000端口。可以试试改吗?
  • 正如我在问题中提到的,我登录机器并在添加配置后手动添加了nginx配置,我可以同时调用idp和审计api。
猜你喜欢
  • 2015-03-27
  • 2020-08-27
  • 2021-10-24
  • 2017-07-24
  • 2021-11-24
  • 2019-01-16
  • 2018-08-27
  • 2021-08-22
  • 2017-04-01
相关资源
最近更新 更多