Skip to content

Instantly share code, notes, and snippets.

@kokuyouwind
Created June 21, 2014 07:20
Show Gist options
  • Save kokuyouwind/299036f997f202ecba4e to your computer and use it in GitHub Desktop.
Save kokuyouwind/299036f997f202ecba4e to your computer and use it in GitHub Desktop.
user nginx;
worker_processes 2;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
use epoll;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
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 backend '$http_x_forwarded_for - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent"';
access_log /var/log/nginx/access.log main;
server_name_in_redirect off;
server_tokens off;
sendfile on;
tcp_nopush off;
keepalive_timeout 5;
client_max_body_size 64m;
client_body_buffer_size 512k;
if_modified_since before;
gzip on;
gzip_http_version 1.0;
gzip_vary on;
gzip_comp_level 6;
gzip_types text/plain
text/xml
text/css
text/javascript
application/xhtml+xml
application/xml
application/rss+xml
application/atom_xml
application/javascript
application/x-javascript
application/x-httpd-php;
gzip_disable "MSIE [1-6]\.";
# proxy cache
proxy_cache_path /var/cache/nginx/proxy_cache levels=1:2
keys_zone=czone:32m max_size=256m inactive=1440m;
proxy_temp_path /var/cache/nginx/proxy_temp;
proxy_cache_key "$scheme://$host$request_uri";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Remote-Addr $remote_addr;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Accept-Encoding "";
proxy_set_header X-UA-Detect $mobile;
proxy_hide_header X-Pingback;
proxy_hide_header Link;
proxy_hide_header ETag;
proxy_connect_timeout 5;
proxy_send_timeout 10;
proxy_read_timeout 120;
proxy_cache_use_stale timeout invalid_header http_500 http_502 http_503 http_504;
proxy_cache_lock on;
proxy_cache_lock_timeout 5s;
# fastcgi cache
#fastcgi_cache_path /var/cache/nginx/fastcgi_cache levels=1:2
# keys_zone=fastcgizone:32m inactive=60m;
#fastcgi_cache_key "$scheme$request_method$host$request_uri";
#fastcgi_cache_use_stale error timeout invalid_header http_500;
#limit_req_zone $request_method zone=method:1m rate=250r/s;
upstream backend {
server unix:/var/run/nginx-backend.sock;
}
upstream phpfpm {
server unix:/var/run/php-fpm.sock;
}
include /etc/nginx/conf.d/*.conf;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment