100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
DevOps

Deploying a Web App Behind Nginx

A practical walkthrough of putting Nginx in front of an application server: reverse proxying, TLS termination, static asset serving, and process management.

PracticeBeginner9 min readJul 10, 2026
Analogies

Deploying a Web App Behind Nginx

Most production web applications don't face the internet directly through their own framework's built-in server. Instead, an application server like Gunicorn, uWSGI, Node's http module, or Puma runs on localhost or a Unix socket, and Nginx sits in front of it, handling TLS termination, static file serving, compression, and connection management, then reverse-proxying dynamic requests to the app. This separation exists because most application frameworks' built-in servers are not designed to handle slow clients, thousands of concurrent connections, or serve static files efficiently — jobs Nginx does very well.

🏏

Cricket analogy: Nginx fronting an app server is like a team's opening batter absorbing the new-ball swing before handing over to the middle order, who can then focus purely on building the innings.

Reverse Proxying to an Application Server

The core directive is proxy_pass inside a location block, which forwards matching requests to your app server, typically over a Unix socket for lowest latency on the same host, or over TCP to 127.0.0.1:port. You should always forward proxy_set_header Host $host, X-Real-IP, and X-Forwarded-For and X-Forwarded-Proto so the application knows the original client IP and whether the original request was HTTPS, since from the app server's point of view every request now appears to come from Nginx on localhost. Timeouts (proxy_connect_timeout, proxy_read_timeout) should be tuned deliberately — the defaults are often too short for slow endpoints like report generation or file uploads.

🏏

Cricket analogy: Forwarding X-Forwarded-For so the app knows the real client IP is like a scorer noting which specific bowler delivered a wicket-taking ball, even though the captain formally reports the figures to the umpire.

TLS Termination and Static Assets

Nginx typically terminates TLS using a certificate from Let's Encrypt (often automated via certbot) or a commercial CA, configured with ssl_certificate and ssl_certificate_key, plus modern settings like ssl_protocols TLSv1.2 TLSv1.3 and a strong ssl_ciphers list. Static assets — JavaScript bundles, CSS, images — should be served directly by Nginx via a location block with root or alias rather than proxied to the app server, since Nginx serves files from disk far more efficiently and can add far-future expires headers and gzip or brotli compression, letting the application server spend its capacity exclusively on dynamic logic.

🏏

Cricket analogy: TLS termination at Nginx is like a stadium's single security gate checking every ticket before fans reach any stand, rather than each individual stand rechecking tickets separately.

certbot's nginx plugin can automatically edit your server blocks to add ssl_certificate directives and set up a redirect from port 80 to 443, plus a systemd timer for renewal — run sudo certbot --nginx -d example.com -d www.example.com and verify auto-renewal with sudo certbot renew --dry-run.

Process Management and Zero-Downtime Deploys

Nginx itself should run under systemd so it restarts automatically on crash and starts on boot, while your app server process (Gunicorn workers, a Node cluster, etc.) is typically managed by its own systemd unit or a process supervisor like pm2, separate from Nginx. For zero-downtime deploys, a common pattern starts a new app server instance on a new socket or port, waits for it to pass a health check, then reloads Nginx's upstream configuration or uses a blue-green upstream swap, so in-flight requests to the old instance finish gracefully before it's terminated — Nginx's own graceful reload (nginx -s reload) never drops connections mid-request, spawning new workers and letting old workers finish their current requests before exiting.

🏏

Cricket analogy: Nginx's graceful reload letting in-flight requests finish is like a substitute fielder coming on between overs rather than mid-delivery, never interrupting a ball actually in play.

Reloading Nginx (nginx -s reload) re-reads configuration and gracefully replaces worker processes, but it does not restart your upstream application server. If you change app code, you still need to restart or redeploy the app server process separately — a reload alone will keep proxying to the old running app process.

nginx
server {
    listen 443 ssl;
    server_name example.com;

    ssl_certificate     /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
    ssl_protocols TLSv1.2 TLSv1.3;

    root /var/www/example/public;

    location /static/ {
        alias /var/www/example/static/;
        expires 30d;
        add_header Cache-Control "public, immutable";
    }

    location / {
        proxy_pass http://unix:/run/example-app.sock;
        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_set_header X-Forwarded-Proto $scheme;
        proxy_read_timeout 60s;
    }
}

server {
    listen 80;
    server_name example.com;
    return 301 https://$host$request_uri;
}
  • Nginx should sit in front of the application server, handling TLS termination, static file serving, and connection management.
  • proxy_pass forwards requests to the app over a Unix socket (lowest latency) or TCP loopback, with proxy_set_header preserving client IP, host, and scheme.
  • Static assets should be served directly by Nginx via root/alias, not proxied, with cache headers and compression applied.
  • certbot automates Let's Encrypt certificate issuance and renewal, typically integrating directly with Nginx server blocks.
  • nginx -s reload gracefully swaps worker processes without dropping in-flight connections, but does not restart the backend app server.
  • Zero-downtime deploys generally require a separate health-checked cutover of the app server, independent of Nginx's own reload mechanism.
  • Default proxy timeouts are often too short for slow endpoints like file uploads or report generation and should be tuned explicitly.

Practice what you learned

Was this page helpful?

Topics covered

#DevOps#NginxStudyNotes#DeployingAWebAppBehindNginx#Deploying#Web#App#Behind#WebDevelopment#StudyNotes#SkillVeris

Frequently Asked Questions

21 categories · pick one to explore

Where can I get free study notes for programming and tech subjects?
SkillVeris offers completely free study notes covering programming and tech subjects, with no signup fees or paywalls. The notes are structured by course and topic, written for quick understanding, and enriched with the Learn Through Hobbies analogy method, so you can revise concepts through cricket, music, gaming, cooking and more.
Are SkillVeris study notes good for exam revision?
Yes, the study notes are designed for efficient revision: each topic answers its heading immediately, keeps explanations concise, and links to related glossary terms and cheat sheets. Students preparing for university exams or certification tests use them as quick revision notes because they distil concepts without the padding of full textbooks.
What subjects do the free study notes cover?
The study notes span the platform's main domains, including AI and machine learning, Python and programming, web development, DevOps, cloud, security and databases. Coverage mirrors the 37 live courses, so notes exist for the topics you are actually studying, and new note sets are added as courses launch.
How are SkillVeris study notes different from regular textbooks?
The notes are answer-first, concise and free, whereas textbooks are long and often expensive. Each section explains one concept directly, then reinforces it through selectable hobby analogies like cricket or cooking. Notes also cross-link to the glossary, blog and cheat sheets, letting you jump to related material instantly instead of flipping pages.
Can I use the developer study material without creating an account?
The study notes are free to access, and SkillVeris does not charge anything for its developer study material at any point. Browsing notes is straightforward from the Study Notes section, and if you want progress tracking, certificates and AI Mentor conversations tied to your learning, a free account unlocks those extras.
Do the study notes explain concepts with analogies?
Yes, this is a signature SkillVeris feature. Study notes use the Learn Through Hobbies method, explaining technical concepts through analogies from twelve domains including cricket, music, gaming, photography, travel, movies, fitness, chess, cooking, finance, business and sports. You can switch the analogy domain instantly to whichever hobby makes the concept click.
Are the revision notes suitable for last-minute exam preparation?
Yes, revision notes on SkillVeris work well for last-minute preparation because every section states the answer in its first sentences, so skimming is genuinely effective. Pair them with the relevant cheat sheet for formulas and syntax, and use the glossary for any unfamiliar term you meet while cramming.
Is there free study material for AI and machine learning?
Yes, SkillVeris provides free study notes across its AI and ML catalogue, covering Python for AI, deep learning frameworks like PyTorch and TensorFlow, Hugging Face Transformers, Large Language Models, RAG, AI agents and MLOps. All of it is free, making it a strong resource for Indian students and global learners alike.
Can beginners understand the study notes, or are they for experts?
Beginners can absolutely use them. The notes are written in plain language, define terms as they appear, and lean on hobby analogies to make abstract ideas concrete. Difficulty scales with the underlying course level, so beginner-course notes stay gentle while advanced-course notes go deeper, and the glossary supports you throughout.
How do study notes connect with SkillVeris courses?
Study notes are organised by course and topic, so they map directly to the structured courses and their 24–40-lesson curriculum. Many learners study a lesson first, then use the matching notes for revision before module assessments and the final exam, where 80 percent is required to pass and earn the certificate.
Are there study notes for Python specifically?
Yes, Python is well covered through notes tied to the Python-focused courses, including Python for AI and ML. Topics span fundamentals through applied machine learning usage. You can reinforce the notes with Python practice in Code Lab, which runs code in your browser with no installation required.
Do the study notes include code examples?
Yes, study notes include code examples wherever a concept is best shown in code, alongside explanations, key points and analogies. Reading a snippet in the notes and then reproducing it yourself in Code Lab is an effective loop, since Code Lab lets you run code in the browser across six languages.
How often is new study material added to SkillVeris?
Study material grows alongside the course catalogue. Whenever new courses join the platform's 37 live courses, matching study notes, glossary entries and cheat sheets are added so the resources stay in sync. Existing notes are also refined over time, so it is worth revisiting topics you studied earlier.
Can I use SkillVeris notes to prepare for technical interviews?
Yes, the notes make excellent interview revision because they compress each concept into direct, answer-first explanations, which mirrors how you should answer interview questions. Combine them with the SkillVeris interview questions feature, which includes readiness scoring, to test whether your revision has actually made you interview-ready.
Are the study notes mobile-friendly for studying on the go?
Yes, the study notes are built to load fast and read comfortably on mobile devices, so you can revise during a commute or between classes. Sections are short and answer-first, which suits small screens, and analogy switching works on mobile too, letting you study anywhere without carrying books.
What is the difference between study notes and cheat sheets?
Study notes explain concepts in depth with context, examples and analogies, making them ideal for learning and revision. Cheat sheets are compact quick-reference summaries of syntax, commands and key facts, ideal once you already understand a topic. Most learners study the notes first, then keep the cheat sheet handy while coding.
Do study notes help if I am stuck on a course lesson?
Yes, reading the matching study notes often clarifies a lesson because the same concept is explained from a different angle, frequently with a different analogy. If you are still stuck, ask the AI Mentor, which answers 24/7 at Quick, Detailed or Deep-dive depth until the idea genuinely makes sense.
Is there free study material for DevOps and cloud topics?
Yes, SkillVeris carries free study notes for DevOps and cloud topics as part of its coverage across 37 live courses. The material suits learners following the DevOps Engineer or Cloud Engineer paths, and it links to related glossary terms and cheat sheets so you can revise the whole toolchain in one place.
Can school or college students in India use these notes for projects?
Yes, students across India and worldwide use SkillVeris notes for coursework, projects and exam preparation, and everything is free, which matters for student budgets. The notes explain concepts clearly enough to cite in project reports, and Code Lab lets you prototype the project code directly in your browser.
How should I combine study notes with other SkillVeris resources?
A proven loop: learn from a course lesson, revise with the matching study notes, look up unfamiliar terms in the glossary, keep the cheat sheet open while practising in Code Lab, and quiz yourself with interview questions. The AI Mentor fills any remaining gaps 24/7, at whatever depth you need.

What Learners Say

Real journeys from the SkillVeris community — swipe for more.

SkillVeris taught me Python through Cricket. Now I’m building real projects and feeling confident!
Arjun S. · B.Tech Student
The best platform for hobby-based learning. Concepts finally stick.
Priya R. · Data Analyst
I went from zero coding to a portfolio of projects — all by learning through my love for gaming. Landed my first internship!
Kabir M. · CS Undergraduate
Trending Topics50 popular tags — tap to explore
Trending CoursesAll 37 free courses — tap to browse