Nginx 502 Bad Gateway on Elastic Beanstalk: Multi-Container Deployment Issue

  Kiến thức lập trình

I’m encountering a 502 Bad Gateway error when deploying my multi-container application to AWS Elastic Beanstalk. I’m using Nginx as a reverse proxy to route traffic to different containers.

Environment:

  • Elastic Beanstalk:
  • Nginx:
  • Docker:
  • Programming languages: [Python + FastAPI]

Configuration:
Nginx configuration:

server {
listen 80;

location /bi_app {
    proxy_pass http://bi_app:8000/;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
}

location / {
    proxy_pass http://platform_app:8000/;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
}

}

docker-compose:

services:
  bi_app:
    build: ./bi_app
    container_name: bi_app
    ports:
      - 8000:8000
    networks:
      - web

  platform_app:
    build: ./platform_app
    container_name: platform_app
    ports:
      - 8001:8000
    networks:
      - web

networks:
  web:
    driver: bridge

You can find the complete code in my GitHub repository: https://github.com/patrickpasquini/dev_ops

eb-stdouterr.log
nginx/error.log; This shouldn’t have an impact

The application should load successfully and route requests to the appropriate backend services.

New contributor

Patrick Pasquini is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT