Mastering Nginx

(Ron) #1

The NGINX HTTP Server


[ 126 ]

location / {

proxy_pass http://upstream.example.com;

}

}

Client interaction


There are a number of ways in which NGINX can interact with clients. This can range
from attributes of the connection itself (IP address, timeouts, keepalive, and so on) to


content negotiation headers. The directives listed in the following table describe how
to set various headers and response codes to get the clients to request the correct page


or serve up that page from its own cache:


Table: HTTP client interaction directives

Directive Explanation
default_type Sets the default MIME type of a response.
This comes into play if the MIME type of
the file cannot be matched to one of those
specified by the types directive.
error_page Defines a URI to be served when an error
level response code is encountered. Adding
an = parameter allows the response code to be
changed. If the argument to this parameter is
left empty, the response code will be taken from
the URI, which must in this case be served by an
upstream server of some sort.
etag Disables automatically generating the
ETag response header for static resources
(default is on).
if_modified_since Controls how the modification time of a
response is compared to the value of the
If-Modified-Since request header:


  • off: The If-Modified-Since header
    is ignored

  • exact: An exact match is made (default)

  • before: The modification time of the
    response is less than or equal to the value
    of the If-Modified-Since header

Free download pdf