The first set of directives will allow you to establish a basic configuration such as the location of the backend server, information to be passed, and how it should be passed:
Directive |
Description |
proxy_pass Context: location, if |
Specifies that the request should be forwarded to the backend server by indicating its location:
Examples:
Using an upstream block: upstream backend { server 127.0.0.1:8080; server 127.0.0.1:8081; } location ~* .php$ { proxy_pass http://backend; } |
proxy_method Context: http, server, location |
Allows the overriding of the HTTP method of the request to be forwarded to the backend server. If you specify POST, for example, all requests forwarded to the backend server will be POST requests. Syntax: proxy_method method; Example: proxy_method POST; |
proxy_hide_header Context: http, server, location |
By default, as Nginx prepares the response received from the backend server to be forwarded back to the client, it ignores some of the headers, such as Date, Server, X-Pad, and X-Accel-*. With this directive, you can specify an additional header line to be hidden from the client. You may insert this directive multiple times with one header name for each. Syntax: proxy_hide_header header_name; Example: proxy_hide_header Cache-Control; |
proxy_pass_header Context: http, server, location |
Related to the previous directive, this directive forces some of the ignored headers to be passed on to the client. Syntax: proxy_pass_header headername; Example: proxy_pass_header Date; |
proxy_pass_request_body proxy_pass_request_headers Context: http, server, location |
Defines whether or not, respectively, the request body and extra request headers should be passed on to the backend server. Syntax: on or off; Default: on |
proxy_redirect Context: http, server, location |
Allows you to rewrite the URL appearing in the Location HTTP header on redirections triggered by the backend server. Syntax: off, default, or the URL of your choice off: Redirections are forwarded as it is. default: The value of the proxy_pass directive is used as the hostname and the current path of the document is appended. Note that the proxy_redirect directive must be inserted after the proxy_pass directive as the configuration is parsed sequentially. URL: Replace a part of the URL by another. Additionally, you may use variables in the rewritten URL. Examples:
|
proxy_next_upstream Context: http, server, location |
When proxy_pass is connected to an upstream block, this directive defines the cases where requests should be abandoned and resent to the next upstream server of the block. The directive accepts a combination of values among the following:
Examples:
|
proxy_next_upstream_timeout Context: http, server, location |
Defines the timeout to be used in conjunction with proxy_next_upstream. Setting this directive to 0 disables it. Syntax: Time value (in seconds) |
proxy_next_upstream_tries Context: http, server, location |
Defines the maximum number of upstream servers tried before returning an error message, to be used in conjunction with proxy_next_upstream. Syntax: Numeric value (default: 0) |