DevOps
Setting Up Nginx as a Reverse Proxy - The Easy Way! π
Learn how to easily connect your web app to a domain name using Nginx as a reverse proxy. A beginner-friendly guide with ready-to-use configs! π

Hey there, fellow developer! π
Ever found yourself scratching your head about how to get your web app connected to a proper domain name? Been there, done that! Today, I'm gonna show you a super simple way to set this up using Nginx as a reverse proxy.
When to use a reverse proxy
A reverse proxy terminates TLS, routes hostnames, and can load-balance. Keep upstream apps bound to localhost, and only expose 80/443 at the edge.
The Problem You're Probably Facing π€
Let me guess:
- You've got your awesome web app running locally β
- You've managed to get it running on your server (way to go!) β
- But... you're stuck figuring out how to connect it to your domain name β
Don't worry - I've got your back!
The Quick Solution πββοΈ
If you're in a hurry and just want the config file, here you go (I won't judge! π):
server {
listen 80;
server_name yourdomain.com www.yourdomain.com;
location / {
proxy_pass http://localhost:3000; # Your app's port
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
Just pop this into /etc/nginx/sites-available/your-app, and you're almost there!
Want to Know What's Actually Happening? π€
Let me break it down in plain English:
listen 80- This tells Nginx to listen for regular HTTP trafficserver_name- Put your domain name here (like coolapp.com)proxy_pass- This is where your app is running (change that 3000 to whatever port you're using)
The other stuff (proxy_set_header etc.) is just making sure everything works smoothly with modern web features.
Quick Setup Steps π οΈ
-
Save the config file:
bashsudo nano /etc/nginx/sites-available/your-app -
Create a link to enable it:
bashsudo ln -s /etc/nginx/sites-available/your-app /etc/nginx/sites-enabled/ -
Test if everything's cool:
bashsudo nginx -t -
Restart Nginx:
bashsudo systemctl restart nginx
And... that's it! You're done! π
Need Help? π
If something's not working:
- Check if your app is actually running
- Make sure your domain is pointing to your server
- Double-check the port number in the config
- Look for errors in
/var/log/nginx/error.log
Pro Tips π‘
- Want HTTPS? Check out Certbot - it's super easy!
- Running multiple apps? Just create multiple server blocks
- Remember to open port 80 in your firewall
That's all folks! Hope this helps you get your app up and running. Happy deploying! π
P.S. If this helped you out, maybe share it with a friend who's stuck with the same problem! π
Written by Shashikant Dwivedi
Engineer, occasional writer, full-time noticer. Based in Prayagraj, India. New essays land roughly twice a month.
Keep reading
Adjacent essays.

DevOps
Getting Free SSL Certificates with Certbot - The No-Stress Guide! π
Oct 26, 2024 Β· 3 min

DevOps
How To Install And Configure Nginx On Your Linux Server
Sep 14, 2024 Β· 4 min

DevOps
Configuring Apache on an AWS Ubuntu Instance: Installation Guide
Sep 14, 2024 Β· 2 min
The newsletter
New articles in your inbox.
Occasional articles on engineering, tooling, and software development practices. No marketing, no fluff β just the article, when it's ready.
Unsubscribe with one click. Your email never leaves the list.