Skip to main content
🔀

Nginx

16 articles in this section

Nginx is the web server behind most of ZevsHost's hosting guides, and this section explains it from architecture to fine-tuning. It starts with installing on Ubuntu and Debian, setting up a server block for several sites on one IP, and understanding the location directive's priority order, the usual reason rules stop matching the way you expect.

From there it covers everyday work: rewrite and return for redirects without loops, reverse proxying through proxy_pass with the right backend headers, wiring up PHP-FPM through sockets and fastcgi_params, configuring SSL/TLS, and moving to HTTP/2 and HTTP/3. Separate guides cover proxy_cache and fastcgi_cache, gzip and Brotli compression, and limit_req plus limit_conn for handling a flood of requests.

There's troubleshooting too: reading the access log and making sense of errors, what 502 and 504 actually mean and where to start looking, and serving static files through try_files, expires, and sendfile without loading down the application.

  • Virtual hosts and location priority
  • Reverse proxying, PHP-FPM, and SSL/TLS
  • Caching, compression, and overload protection
What Is Nginx: Architecture and Difference from Apache Explaining what Nginx is: master and worker processes, the event-driven model, and key differences from Apache in practice. Installing Nginx on Ubuntu and Debian: Two Ways and Versions A step-by-step guide to installing Nginx on Ubuntu and Debian: the distro package or the official nginx.org repository. Server Blocks in Nginx: Virtual Hosts for Multiple Sites How to set up an Nginx server block: sites-available, sites-enabled, listen, server_name, and several sites on one IP address. The Nginx Location Directive: Rule Order and Priority How Nginx picks the right location block: the =, ~, ~*, ^~ modifiers, rule evaluation order, and common config mistakes. Nginx rewrite vs return: Setting Up Clean Redirects The difference between rewrite and return in Nginx, the last and break flags, codes 301 and 302, and redirect examples. Reverse Proxy in Nginx: proxy_pass and Backend Headers Reverse proxy in Nginx: how to configure proxy_pass, forward client headers to the backend, and keep the visitor IP intact. Nginx Optimization on a VPS: Performance and Caching How to optimize Nginx on a VPS: worker_processes, gzip compression, FastCGI cache, browser caching, rate limiting, HTTP/2, and buffer tuning for high load. Nginx and PHP-FPM Together: Sockets, Pools, fastcgi_params How to connect Nginx to PHP-FPM via a socket or TCP, tune a pool and fastcgi_params so a PHP site survives traffic spikes. SSL/TLS in Nginx: Certificates, Protocols, and Ciphers Setting up SSL/TLS in Nginx: certificate paths, protocol and cipher choices, redirecting to HTTPS, and checking the result. HTTP/2 and HTTP/3 (QUIC) in Nginx: Enabling and Testing How to enable HTTP/2 and HTTP/3 over QUIC in Nginx, which version you need, and how to check the browser is really using the new protocol. Caching in Nginx: proxy_cache and fastcgi_cache in Practice How to set up caching in Nginx with proxy_cache and fastcgi_cache: cache zone, key, lifetime, and purging the cache for specific pages. Gzip and Brotli Compression in Nginx: Setup Guide How to enable gzip and Brotli in Nginx: gzip_comp_level settings, installing the Brotli module, and testing compression with curl. limit_req and limit_conn in Nginx: Rate Limiting Guide How to configure limit_req and limit_conn in Nginx: memory zones, burst, nodelay, and 429/503 response codes when limits are exceeded. Nginx Logs: access_log Format, Rotation, and Analysis How to configure the Nginx log format, enable rotation with logrotate, and parse access.log and error.log using grep and awk. Nginx 502 and 504 Errors: How to Find and Fix the Cause Why Nginx returns 502 Bad Gateway and 504 Gateway Timeout: reading error.log, checking PHP-FPM, and tuning proxy_pass timeouts. Serving Static Files in Nginx: try_files and expires How to configure fast static file delivery in Nginx: try_files, expires, sendfile, tcp_nopush, and browser caching directives.