[cheatsheets] nginx
ALB & Nginx proxying
Open the Nginx configuration file:
Modify the configuration to listen on port 80 and proxy to your application on port 8080:
Save and exit the editor.
Test the Nginx configuration:
If the test is successful, restart Nginx:
This configuration:
Listens on port 80, which is typically where the ALB will forward traffic
Proxies all requests to
http://localhost:8080
Sets appropriate headers, including
X-Forwarded-Proto
which the ALB uses to indicate whether the original request was HTTP or HTTPS
For your AWS setup:
Ensure your EC2 security group allows inbound traffic on port 80 from the ALB's security group.
In your ALB configuration:
Set up HTTPS listeners (port 443) with your SSL/TLS certificate
Configure rules to forward traffic to your EC2 instance(s) on port 80
Optionally, set up an HTTP to HTTPS redirect rule on the ALB
Make sure your application is actually running and listening on port 8080 on the EC2 instance.
Last updated
Was this helpful?