Nginx configuration is organized in nested contexts. The main context sets global options like worker_processes. The events context controls connection limits such as worker_connections. The http context groups HTTP server settings. Inside http, server contexts define virtual hosts. Each server can have multiple location contexts to handle specific URL paths. Directives must be placed in the correct context to take effect. For example, worker_connections belongs in events, while root belongs in location or server. When nginx starts, it reads the config top-down entering each context and applying directives. When a request arrives, nginx matches it to a server and location context to serve content accordingly.