Well without wasting any time let us get into the point that how NGINX works step by step

1. NGINX receives a request from a client (usually a web browser) for a resource, such as a webpage or image.

2. NGINX checks its configuration to determine how to handle the request. This configuration includes things like which server blocks (virtual hosts) should handle the request, and what upstream servers to proxy to if necessary.

3. NGINX determines which server block should handle the request based on the request's domain name or IP address.

4. NGINX passes the request to the appropriate server block, which may include executing any configured rewrite rules or redirecting the request to another URL.

5.If the server block needs to proxy the request to another server, NGINX passes the request to the appropriate upstream server.

6. The upstream server processes the request and sends a response back to NGINX.

7. NGINX receives the response and applies any necessary filters, such as gzip compression or adding headers.

8. NGINX sends the response back to the client that made the request.

9.The client receives the response and displays the requested resource, such as a webpage or image, in the web browser.

This process is repeated for each request that NGINX receive.