Leo*_*lva 5 nginx service-discovery amazon-web-services amazon-route53 aws-fargate
我的集群上有两个服务:myapp-service 和 nginx-service。我正在使用服务发现来连接两者,一切正常。
当我部署新版本的 myapp-service 并且它带有新的私有(和公共)IP 地址时,就会出现问题。部署后,我看到 IP 在 Route 53 上已正确更新,但当我尝试通过 nginx 访问我的应用程序时,它返回一个错误网关。当我查看 Cloudwatch 上的 nginx 日志时,我可以看到 nginx 正在尝试连接到 myapp-service 的旧私有 IP 地址。
这是我的 nginx 配置(default.conf),marketplace-service.local 是我在 Route 53 上的注册表。
upstream channels-backend {
server marketplace-service.local:8000;
}
server {
listen 80;
location / {
proxy_pass http://channels-backend;
}
}
Run Code Online (Sandbox Code Playgroud)
有人可以帮我发现我在这里缺少什么吗?
谢谢
小智 0
我不知道upstream部分。
upstream channels-backend {
server marketplace-service.local:8000;
}
Run Code Online (Sandbox Code Playgroud)
但我确信server一部分。对于Fargate,localhost被使用所以添加server_name localhost;。然后添加如下所示的 4 行代码来location阻止。
server {
listen 80;
server_name localhost;
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://channels-backend;
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
595 次 |
| 最近记录: |