Using nginx to redirect to a different port

Problem

You have a docker container with an application running in a port different than port 80 (ie port 3000), and would like to access it without specifying the port, by using the domain name only.

Solution

Use the nginx proxy_pass as follows:

server {
  listen 80;

  server_name your_server_domain_name.com;
  location / {
    proxy_set_header  X-Real-IP $remote_addr;
    proxy_set_header  Host $http_host;
    proxy_pass        http://127.0.0.1:3000;
  }
}