Recent Posts

Nginx external and internal requests

Nginx differentiates external and internal requests. External requests directly originate from the client; but, internal requests are triggered by Nginx via specific directives: try_files, error_page, index, rewrite, and more.

Nginx external requests

The URI is matched against possible location blocks:

server {


	location = /sitemap {

A client request to will be matched against the above location block.

Nginx internal requests

There are two different kinds of internal requests:

  1. Internal redirects: Nginx redirects the client requests internally. The URI is changed, and then the request may match another location block and become eligible for different settings. The most common case of internal redirects is rewrite the request URI for some purposes: seo, migrate from Apache, and so forth.
  2. Sub-requests: Additional requests that are triggered internally to generate content that is complementary to the main request. A simple example would be with the Addition module. The add_after_body directive allows you to specify a URI that will be processed after the original one, the resulting content being appended to the body of the original request. The SSI module also makes use of sub-requests to insert content with the include command.

Share this Post