Backend Development 13 min read

Nginx: A Comprehensive Guide

This article provides an in-depth overview of Nginx, covering its introduction, architecture, and various modules, including real IP and rewrite modules, with practical examples and configuration details.

New Oriental Technology
New Oriental Technology
New Oriental Technology
Nginx: A Comprehensive Guide

Nginx [engine x] was initially developed by Lgor Sysoev. According to Netcraft data, by September 2020, Nginx served or proxied 25.76% of websites, holding approximately 34.03% of the market share.

Nginx is widely used as:

HTTP server

Reverse proxy server

Mail proxy server

General TCP/UDP proxy

The Nginx service consists of a Master process and multiple Worker processes. The Master process handles configuration reading and maintenance, while Worker processes manage actual request processing.

Nginx's 11 execution phases and corresponding HTTP modules are detailed, including the post_read phase for obtaining the original client IP address and the rewrite phase for URL manipulation.

The realip module is used to obtain the client's real IP address, with configuration examples and practical testing results.

The rewrite module includes directives like break, if, return, and rewrite, with examples demonstrating their usage in modifying request paths and handling conditional logic.

The access phase involves modules like ngx_http_access_module for IP-based access control and ngx_http_auth_basic_module for HTTP basic authentication.

The auth_request module allows delegating authentication to a separate service, with configuration examples and testing results.

backend developmentAccess ControlAuthenticationnginxhttp serverReverse ProxyWeb ServerServer ArchitectureReal IPRewrite Module
New Oriental Technology
Written by

New Oriental Technology

Practical internet development experience, tech sharing, knowledge consolidation, and forward-thinking insights.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.