
- Matches incoming requests (usually by
Hostheader andlistenport). - Applies the configuration for that site (root directory, proxying, rewrites, TLS, etc.).
- Lets one NGINX process host many sites (each with its own behavior and files).
- A request for
google.comis handled by the virtual server whoseserver_namematchesgoogle.com. - A request for
mail.google.comis routed to a different virtual server that may have different document root or proxy settings.

server_name can be an IP address or a DNS hostname.
http://wiki.example.com:8080).
Ports and user experience
Best practices and deployment tips
- Keep each site’s configuration in a separate file and enable them selectively (for example,
/etc/nginx/sites-available/with symlinks in/etc/nginx/sites-enabled/). This minimizes the blast radius of configuration errors and simplifies automation. - Use a single reverse proxy on ports 80/443 to route traffic to internal ports (avoids exposing nonstandard ports to users).
- Consolidate TLS termination at the front-end reverse proxy, or use tools like Certbot/ACME to automate certificates per site.
- Test configuration changes with
nginx -tbefore reloading:sudo nginx -t && sudo systemctl reload nginx.
Store each site’s configuration in its own file and enable them individually (for example, with
/etc/nginx/sites-available/ and /etc/nginx/sites-enabled/). This reduces blast radius when editing configs and makes management easier.- NGINX official documentation — Server Blocks (server context)
- NGINX Beginner’s Guide — How to Set Up Server Blocks
- Debian/Ubuntu NGINX packaging — sites-available and sites-enabled pattern
/var/www/, create per-site server block files, test configuration, and reload NGINX to see multiple virtual servers served from a single NGINX instance.