0

I created an HTTP API with ec2 instance integration. Two python applications are running on the ec2 instance on ports 8002 and 5005. There is an nginx reverse proxy running on ec2 instance that should direct requests from API gateway to the correct port based on the server name. But it always end up directing traffic to the default server. Any idea whats the issue?

This is how my nginx config looks like:

server {

  listen 80 default_server;

  server_name example1.com;

  location / {

    proxy_set_header X-Real-IP $remote_addr;

    proxy_pass http://localhost:8002;

  }
}

server {

  listen 80;

  server_name example2.com;

  location / {

    proxy_set_header X-Real-IP $remote_addr;

    proxy_pass http://localhost:5005;

  }
}

I tried changing the nginx config couple of times but nothing worked.

Andrii Bodnar
  • 1,672
  • 2
  • 17
  • 24

0 Answers0