Nginx external and internal requests

By:    Updated: April 18,2017

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 -- via nginx location:

server {
	server_name www.valinv.com;

        #...

	location = /sitemap {
		#...
	}
}

A client request to https://www.valinv.com/sitemap will be matched against the above location block.

Nginx internal requests

There are two different kinds of internal requests -- via nginx try_files, nginx error_page, nginx index, nginx rewrite:

  • 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.
  • 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.
More in Development Center
New on Valinv
Related Articles
Sponsored Links