Skip to content

Instantly share code, notes, and snippets.

@xluffy
Last active April 24, 2016 04:07
Show Gist options
  • Save xluffy/32fe9b75be0dcc12896f to your computer and use it in GitHub Desktop.
Save xluffy/32fe9b75be0dcc12896f to your computer and use it in GitHub Desktop.
Main config nginx for static server
# generate by ansible
user nginx nginx;
worker_processes 2;
worker_rlimit_nofile 8192;
events {
use epoll;
worker_connections 8192;
}
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
http {
server_tokens off;
include mime.types;
default_type application/octet-stream;
charset_types text/xml text/plain application/x-javascript application/rss+xml text/css application/javascript application/json;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
log_format json
'{'
'"remote_addr": "$remote_addr",'
'"remote_user": "$remote_user",'
'"time_local": "$time_local",'
'"request": "$request",'
'"status": $status,'
'"body_bytes_sent": $body_bytes_sent,'
'"http_referer": "$http_referer",'
'"http_user_agent": "$http_user_agent",'
'"pipe":"$pipe",'
'"request_time": "$request_time",'
'}'
;
access_log /var/log/nginx/access.log main;
keepalive_timeout 20;
sendfile on;
tcp_nopush on;
# Compression
gzip on;
gzip_comp_level 5;
gzip_min_length 256;
gzip_proxied any;
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/rdf+xml
application/rss+xml
application/schema+json
application/vnd.geo+json
application/vnd.ms-fontobject
application/x-font-ttf
application/x-javascript
application/x-web-app-manifest+json
application/xhtml+xml
application/xml
font/eot
font/opentype
image/bmp
image/svg+xml
image/vnd.microsoft.icon
image/x-icon
text/cache-manifest
text/css
text/javascript
text/plain
text/vcard
text/vnd.rim.location.xloc
text/vtt
text/x-component
text/x-cross-domain-policy
text/xml;
include sites-enabled/*.conf;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment