Skip to content

Instantly share code, notes, and snippets.

@dvl
Created November 18, 2013 14:22
Show Gist options
  • Save dvl/7528556 to your computer and use it in GitHub Desktop.
Save dvl/7528556 to your computer and use it in GitHub Desktop.
nginx.conf for cloudflare
user apache;
worker_processes auto;
worker_rlimit_nofile 8192;
pid /var/run/nginx.pid;
events {
worker_connections 2048;
multi_accept on;
use epoll;
accept_mutex off;
}
http {
## Mime
include mime.types;
default_type text/html;
charset UTF-8;
## Log
access_log off;
error_log /var/log/nginx/error.log crit;
## Proxy
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffers 8 16k;
proxy_buffer_size 32k;
## Conn
client_max_body_size 32M;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 20;
client_header_timeout 20;
client_body_timeout 20;
reset_timedout_connection on;
send_timeout 20;
limit_conn_zone $binary_remote_addr zone=addr:5m;
limit_conn addr 100;
server_tokens off;
## GZip
gzip on;
# gzip_static on;
gzip_proxied any;
gzip_min_length 256;
gzip_comp_level 4;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
## File cache
open_file_cache max=100000 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 2;
open_file_cache_errors on;
## CF
set_real_ip_from 204.93.240.0/24;
set_real_ip_from 204.93.177.0/24;
set_real_ip_from 199.27.128.0/21;
set_real_ip_from 173.245.48.0/20;
set_real_ip_from 103.22.200.0/22;
set_real_ip_from 141.101.64.0/18;
set_real_ip_from 108.162.192.0/18;
real_ip_header CF-Connecting-IP;
include /etc/nginx/conf.d/*.conf;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment