1

I am using a Docker container with an image based on python:2.7-alpine. I would like to have all the requests to ec2.us-west-2.amazonaws.com to be redirected to 127.0.0.1:3000.
How can I achieve that?
I am running a dummy AWS API endpoint locally in the container and I would like that all the requests to AWS EC2 go to my dummy endpoint on port 3000. Unfortunately, I cannot override the API endpoint, that is the reason because I am after a solution that may include IP tables and some hacks in the hosts file.

1 Answers1

0

To let nginx act as a reverse proxy for your Docker container, you'd add the following to its config

server {
  server_name ec2.us-west-2.amazonaws.com;

  location / {
    proxy_pass_header Authorization;
    proxy_pass http://127.0.0.1:3000;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_http_version 1.1;
    proxy_set_header Connection "";
    proxy_buffering off;
    client_max_body_size 0;
    proxy_read_timeout 36000s;
    proxy_redirect off;
  }
}

If you'd like to know what you're doing, have a look at https://www.techandme.se/set-up-nginx-reverse-proxy/

Gerard H. Pille
  • 2,569
  • 1
  • 13
  • 11