Ubuntu Unleashed 2019 Edition: Covering 18.04, 18.10, 19.04

(singke) #1

http—This section contains the base settings for HTTP access:


    Leave   the include and default_type    lines   alone   unless  you
enjoy trying to figure out why content is not being displayed or you
know you must adjust which types of content are permitted.
Feel free to adjust the location of the access_log, which records
all attempts to connect to your server, or comment out the line to
disable it.
sendfile is used when you permit Nginx to ignore the contents
of the file it is sending, such as when serving larger files that do not
require a multiple-request-and-confirmation system when being
served, thereby freeing system resources for items that do require
Nginx to watch over. It is recommended that you leave this setting
on unless you know why you are turning it off, as it saves resources
when serving things like graphics.
tcp_nopush sends HTTP response headers in one packet, and this
is actually a pretty good thing, but experimenting with it is okay.
tcp_nodelay is for use with items that do not require a response,
but most general web use does demand responses, so this is often
best commented out, although trying it to see if it makes a
difference in your circumstance is okay.
keepalive_timeout sets the number of seconds that Nginx
will keep a connection open when a request is made. The default is
to keep this connection open for over a minute, which seems a bit
odd since you have a limited number of connections available, and
keeping a connection alive prevents another requester from using
that slot again until the timeout occurs. Setting this to a low number
like 2 or 3 seconds seems to permit more people to connect in a
minute than would be able to do so otherwise. If you are serving a
website with little traffic, the setting doesn’t matter. If you have a
lot of traffic, a lower number is generally a good idea.
gzip allows the use of on-the-fly gzip compression, which can
make data transfers a bit faster.
include defines files that are located outside the nginx.conf
file that are to be read by Nginx and used for its configuration. You
can include multiple files; just create a new line for each. Our
example includes a directive to include everything listed in a
directory that is generally used for virtual hosts, as described in the
section “Virtual Hosting,” which follows. You could place a
Free download pdf