Skip to content

Instantly share code, notes, and snippets.

@SvenAlHamad
Created August 31, 2013 12:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save SvenAlHamad/6397956 to your computer and use it in GitHub Desktop.
Save SvenAlHamad/6397956 to your computer and use it in GitHub Desktop.
#user
user www-data www-data;
# This number should be, at maximum, the number of CPU cores on your system.
# (since nginx doesn't benefit from more than one worker per CPU.)
worker_processes 1;
#pid
pid /var/run/nginx.pid;
events{
use epoll;
multi_accept on;
# Determines how many clients will be served by each worker process.
# (Max clients = worker_connections * worker_processes)
# "Max clients" is also limited by the number of socket connections available on the system (~64k)
worker_connections 1024;
}
http{
include mime.types;
default_type application/octet-stream;
# Load config files from the /etc/nginx/conf.d directory
include /etc/nginx/conf.d/*.conf;
# only log critical errors
error_log /var/log/nginx/error.log;
# turn off access log
access_log /var/log/nginx/access.log;
# cache informations about FDs, frequently accessed files
# can boost performance, but you need to test those values
open_file_cache max=50000 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 2;
open_file_cache_errors on;
# cache zones for proxy
proxy_buffering on;
proxy_cache_valid any 10m;
proxy_cache_path /var/cache/nginx levels=1:2
keys_zone=microcache:5m
max_size=1000m inactive=600m;
proxy_temp_path /var/cache/tmp;
proxy_buffer_size 4k;
proxy_buffers 100 8k;
proxy_cache_key "$scheme$host$request_uri";
# copies data between one FD and other from within the kernel
# faster then read() + write()
sendfile on;
# send headers in one peace, its better then sending them one by one
tcp_nopush on;
# don't buffer data sent, good for small data bursts in real time
tcp_nodelay on;
# server will close connection after this time
keepalive_timeout 30;
# allow the server to close connection on non responding client, this will free up memory
reset_timedout_connection on;
# request timed out -- default 60
client_body_timeout 10;
# if client stop responding, free up memory -- default 60
send_timeout 2;
# reduce the data that needs to be sent over network
gzip on;
gzip_min_length 10240;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml;
gzip_disable "MSIE [1-6]\.";
# security
server_tokens off;
# sites
include /etc/nginx/sites-enabled/*;
}
server {
listen 80;
index index.php index.html index.htm;
server_name web.com;
# cache static files
location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
expires 365d;
access_log off;
add_header Cache-Control public;
root /var/www/oldwebiny/sites/web;
}
location / {
proxy_pass http://127.0.0.1:8080;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_cache microcache;
proxy_cache_valid 200 302 304 10m;
proxy_cache_valid 301 1h;
proxy_cache_valid any 1m;
}
location ~ /\.ht {
deny all;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment