

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

# 配置代理服务器
<a name="dotnet-linux-platform-nginx"></a>

AWS Elastic Beanstalk 使用 [NGINX](https://www.nginx.com/) 作为反向代理将请求中继到您的应用程序。Elastic Beanstalk 提供一个默认 NGINX 配置，您可以扩展该配置，也可以使用您自己的配置完全覆盖该配置。

默认情况下，Elastic Beanstalk 将 NGINX 代理配置为通过端口 5000 向您的应用程序转发请求。您可以覆盖默认端口，方法是将 `PORT` [环境属性](dotnet-linux-platform.md#dotnet-linux-options-properties)设置为主应用程序侦听的端口。

**注意**  
应用程序侦听的端口不会影响 NGINX 服务器为了从负载均衡器接收请求而侦听的端口。

**在平台版本上配置代理服务器**  
所有 AL2023/AL2 平台都支持统一的代理配置功能。有关在运行 AL2023 /的平台版本上配置代理服务器的更多信息AL2，请参阅[反向代理配置](platforms-linux-extend.proxy.md)。

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

**Example `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;
}
```