Created
May 17, 2015 05:20
-
-
Save itsimba/e4a99de96caec869ade6 to your computer and use it in GitHub Desktop.
nginx config
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
#user nobody; | |
worker_processes 8; | |
worker_cpu_affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000000; | |
#error_log logs/error.log; | |
#error_log logs/error.log notice; | |
#error_log logs/error.log info; | |
#pid logs/nginx.pid; | |
worker_rlimit_nofile 102400; | |
events { | |
use epoll; | |
worker_connections 102400; | |
} | |
# load modules compiled as Dynamic Shared Object (DSO) | |
# | |
#dso { | |
# load ngx_http_fastcgi_module.so; | |
# load ngx_http_rewrite_module.so; | |
#} | |
http { | |
include 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"' | |
'"request_time $request_time"' | |
'"upstream_response_time $upstream_response_time"'; | |
#access_log logs/access.log main; | |
server_names_hash_bucket_size 128; | |
client_header_buffer_size 4k; | |
large_client_header_buffers 4 4k; | |
client_max_body_size 8m; | |
sendfile on; | |
tcp_nopush on; | |
keepalive_timeout 60; | |
server_tokens off; | |
fastcgi_connect_timeout 300; | |
fastcgi_send_timeout 300; | |
fastcgi_read_timeout 300; | |
fastcgi_buffer_size 64k; | |
fastcgi_buffers 16 64k; | |
fastcgi_busy_buffers_size 128k; | |
fastcgi_temp_file_write_size 128k; | |
#增加调试信息 | |
add_header X-Cache-CFC "$upstream_cache_status - $upstream_response_time"; | |
#fastcgi_temp_path /data/fastcgi_temp; | |
#fastcgi_cache_path /usr/local/nginx/fastcgi_cache levels=1:2 keys_zone=ngx_fcgi_cache:512m inactive=1d max_size=10g; | |
#fastcgi_cache ngx_fcgi_cache; | |
fastcgi_cache_valid 200 302 1h; | |
fastcgi_cache_valid 301 1d; | |
fastcgi_cache_valid any 1m; | |
fastcgi_cache_min_uses 1; | |
fastcgi_cache_methods GET; | |
fastcgi_cache_use_stale error timeout invalid_header http_500; | |
#fastcgi_cache_key "$scheme$request_method$host$request_uri"; | |
fastcgi_ignore_client_abort on; | |
open_file_cache max=102400 inactive=20s; | |
open_file_cache_min_uses 1; | |
open_file_cache_valid 30s; | |
tcp_nodelay on; | |
gzip on; | |
gzip_min_length 1k; | |
gzip_buffers 4 16k; | |
gzip_http_version 1.0; | |
gzip_comp_level 2; | |
gzip_types text/plain application/x-javascript text/css application/xml; | |
gzip_vary on; | |
#limit_req_log_level warn; | |
#限制来自单个IP地址的请求处理频率 | |
#limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s; | |
include vhost/*.conf; | |
server { | |
listen 80; | |
server_name www.test.com; | |
root /home/www; | |
index index.html index.htm index.php; | |
#charset koi8-r; | |
#access_log logs/host.access.log main; | |
#error_page 404 /404.html; | |
# redirect server error pages to the static page /50x.html | |
# | |
error_page 500 502 503 504 /50x.html; | |
location = /50x.html { | |
} | |
# proxy the PHP scripts to Apache listening on 127.0.0.1:80 | |
# | |
#location ~ \.php$ { | |
# proxy_pass http://127.0.0.1; | |
#} | |
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 | |
# | |
location ~ \.php { | |
#fastcgi_pass 127.0.0.1:9000; | |
fastcgi_pass unix:/dev/shm/php-fcgi.sock; | |
fastcgi_index index.php; | |
include fastcgi_params; | |
set $path_info ""; | |
set $real_script_name $fastcgi_script_name; | |
if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") { | |
set $real_script_name $1; | |
set $path_info $2; | |
} | |
fastcgi_param SCRIPT_FILENAME $document_root$real_script_name; | |
fastcgi_param SCRIPT_NAME $real_script_name; | |
fastcgi_param PATH_INFO $path_info; | |
} | |
# deny access to .htaccess files, if Apache's document root | |
# concurs with nginx's one | |
# | |
location ~ /\.ht { | |
deny all; | |
} | |
} | |
# another virtual host using mix of IP-, name-, and port-based configuration | |
# | |
#server { | |
# listen 8000; | |
# listen somename:8080; | |
# server_name somename alias another.alias; | |
# location / { | |
# root html; | |
# index index.html index.htm; | |
# } | |
#} | |
# HTTPS server | |
# | |
#server { | |
# listen 443; | |
# server_name localhost; | |
# ssl on; | |
# ssl_certificate cert.pem; | |
# ssl_certificate_key cert.key; | |
# ssl_session_timeout 5m; | |
# ssl_protocols SSLv2 SSLv3 TLSv1; | |
# ssl_ciphers HIGH:!aNULL:!MD5; | |
# ssl_prefer_server_ciphers on; | |
# location / { | |
# root html; | |
# index index.html index.htm; | |
# } | |
#} | |
server { | |
listen 80 default; | |
return 400; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment