server { listen 80; server_name localhost; return 301 https://$host$request_uri; } server { listen 443 ssl; server_name localhost; ssl_certificate /etc/ssl/certs/nginx.crt; ssl_certificate_key /etc/ssl/certs/nginx.key; location / { try_files $uri @app_proxy; } location @app_proxy { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_redirect off; proxy_pass http://app:5000; # Use the service name 'app' and the internal port '80' } }