Last active
February 5, 2018 19:03
-
-
Save phwelo/d365bdd066a87e53ab6756467452c560 to your computer and use it in GitHub Desktop.
Basic nginx configuration #nginx #configuration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
worker_processes 1; | |
error_log /dev/stdout info; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
# Hide nginx version information. | |
server_tokens off; | |
access_log /dev/stdout; | |
# Specify MIME types for files. | |
include mime.types; | |
default_type application/octet-stream; | |
# Update charset_types to match updated mime.types. | |
# text/html is always included by charset module. | |
charset_types text/css text/plain text/vnd.wap.wml application/javascript application/json application/rss+xml application/xml; | |
# How long to allow each connection to stay idle. | |
# Longer values are better for each individual client, particularly for SSL, | |
# but means that worker connections are tied up longer. | |
keepalive_timeout 20s; | |
# Speed up file transfers by using sendfile() to copy directly | |
# between descriptors rather than using read()/write(). | |
# For performance reasons, on FreeBSD systems w/ ZFS | |
# this option should be disabled as ZFS's ARC caches | |
# frequently used files in RAM by default. | |
sendfile on; | |
# Don't send out partial frames; this increases throughput | |
# since TCP frames are filled up before being sent out. | |
tcp_nopush on; | |
# Enable gzip compression. | |
gzip on; | |
# Compression level (1-9). | |
# 5 is a perfect compromise between size and CPU usage, offering about | |
# 75% reduction for most ASCII files (almost identical to level 9). | |
gzip_comp_level 5; | |
# Don't compress anything that's already small and unlikely to shrink much | |
# if at all (the default is 20 bytes, which is bad as that usually leads to | |
# larger files after gzipping). | |
gzip_min_length 256; | |
# Compress data even for clients that are connecting to us via proxies, | |
# identified by the "Via" header (required for CloudFront). | |
gzip_proxied any; | |
# Tell proxies to cache both the gzipped and regular version of a resource | |
# whenever the client's Accept-Encoding capabilities header varies; | |
# Avoids the issue where a non-gzip capable client (which is extremely rare | |
# today) would display gibberish if their proxy gave them the gzipped version. | |
gzip_vary on; | |
# Compress all output labeled with one of the following MIME-types. | |
gzip_types | |
application/atom+xml | |
application/javascript | |
application/json | |
application/ld+json | |
application/manifest+json | |
application/rss+xml | |
application/vnd.geo+json | |
application/vnd.ms-fontobject | |
application/x-font-ttf | |
application/x-web-app-manifest+json | |
application/xhtml+xml | |
application/xml | |
font/opentype | |
image/bmp | |
image/svg+xml | |
image/x-icon | |
text/cache-manifest | |
text/css | |
text/plain | |
text/vcard | |
text/vnd.rim.location.xloc | |
text/vtt | |
text/x-component | |
text/x-cross-domain-policy; | |
server { | |
listen 80; | |
server_name localhost; | |
root /usr/share/nginx/html; | |
# Any route that doesn't have a file extension (e.g. /devices) | |
location / { | |
try_files $uri /index.html; | |
} | |
location = /index.html { | |
root /usr/share/nginx/html; | |
index index.html; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment