为您配置代理服务器。 NETLinux 上的 Core Elastic Beanstalk 环境 - AWS Elastic Beanstalk

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

为您配置代理服务器。 NETLinux 上的 Core Elastic Beanstalk 环境

AWS Elastic Beanstalk NGINX用作反向代理,将请求中继到您的应用程序。Elastic Beanstalk 提供了NGINX一种默认配置,您可以使用自己的配置对其进行扩展或完全覆盖。

默认情况下,Elastic Beanstalk NGINX 将代理配置为通过端口 5000 将请求转发到您的应用程序。您可以覆盖默认端口,方法是将 PORT 环境属性设置为主应用程序侦听的端口。

注意

您的应用程序监听的端口不会影响NGINX服务器为接收来自负载均衡器的请求而监听的端口。

在平台版本上配置代理服务器

所有 AL2 023/ AL2 平台都支持统一的代理配置功能。有关在运行 AL2 023/ 的平台版本上配置代理服务器的更多信息AL2,请参阅。在 Elastic Beanstalk 上配置反向代理

以下示例配置文件扩展了您的环境NGINX配置。该配置会将发往 /api 的请求定向到侦听 Web 服务器上的 5200 端口的第二个 Web 应用程序。默认情况下,Elastic Beanstalk 会将请求转发到侦听 5000 端口的单个应用程序。

01_custom.conf
location /api { proxy_pass http://127.0.0.1:5200; 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; }