Last active
August 29, 2015 14:16
-
-
Save carlessanagustin/e68045401c4e7fcdc7fe to your computer and use it in GitHub Desktop.
Nginx app frontend / Load balancer / Static assets caching (not tested)
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
# Number of worker processes. Set it to the number of available CPU cores as a good start value or use 'auto' to autodetect it | |
worker_processes 4; | |
# User and group used by worker processes | |
user www-data www-data; | |
# Skip superfluous info in the main error log file | |
error_log /var/log/nginx/error_log error; | |
# Limit number of files a worker process can open | |
worker_rlimit_nofile 1024; | |
pid /var/run/nginx.pid ; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
server_names_hash_bucket_size 64; | |
include /etc/nginx/mime.types; | |
default_type application/octet-stream; | |
access_log /var/log/nginx/access.log; | |
sendfile on; | |
#tcp_nopush on; | |
#keepalive_timeout 0; | |
keepalive_timeout 65; | |
tcp_nodelay on; | |
gzip on; | |
gzip_http_version 1.1; | |
gzip_vary on; | |
gzip_comp_level 6; | |
gzip_proxied any; | |
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; | |
gzip_buffers 16 8k; | |
include /etc/nginx/conf.d/*.conf; | |
include /etc/nginx/sites-enabled/*; | |
} | |
# Nginx app frontend + Load balancer | |
upstream projectname { | |
server 22.22.22.2:3000; | |
server 22.22.22.3:3000; | |
server 22.22.22.5:3000; | |
} | |
server { | |
listen 80; | |
charset utf-8; | |
server_name your-site.com www.your-site.com; | |
location / { | |
proxy_pass http://projectname; | |
} | |
# Static assets caching | |
location ~* \.(css|js|gif|jpe?g|png)$ { | |
expires 168h; | |
} | |
# Static assets caching | |
location /api { | |
expires 10m; | |
} | |
} | |
# more https://gist.github.com/learncodeacademy/ebba574fc3f438c851ae | |
# more https://github.com/Stolz/linux-cheat-sheets/blob/master/nginx.md |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment