首页 > 代码库 > 03.Nginx配置
03.Nginx配置
user www www;
worker_processes 4;
worker_cpu_affinity 0001 0010 0100 1000;
error_log /data1/logs/nginx-1.7.4/error.log debug_http;
pid /data/program/nginx-1.7.4/logs/nginx.pid;
worker_rlimit_nofile 204800;
events {
use epoll;
worker_connections 20480;
multi_accept on;
accept_mutex off;
}
http {
include mime.types;
default_type application/octet-stream;
log_format access ‘$http_x_forwarded_for $remote_addr [$time_local] "$request" ‘
‘$status $body_bytes_sent "$http_referer" ‘
‘"$http_user_agent"‘;
sendfile on;
tcp_nodelay on;
tcp_nopush on;
server_tokens off; #关闭版本显示
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 256k;
fastcgi_buffers 16 256k;
fastcgi_busy_buffers_size 512k;
fastcgi_temp_file_write_size 512k;
#设定请求缓冲
server_names_hash_bucket_size 128;
client_body_buffer_size 128K;
client_header_buffer_size 16k;
large_client_header_buffers 4 64k;
client_max_body_size 1G;
client_body_timeout 30;
client_header_timeout 10;
keepalive_timeout 65;
send_timeout 30;
reset_timedout_connection on;
proxy_connect_timeout 110;
proxy_send_timeout 110;
proxy_read_timeout 110;
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
proxy_temp_file_write_size 64m;
proxy_ignore_client_abort on;
open_file_cache max=204800 inactive=20s;
open_file_cache_min_uses 1;
open_file_cache_valid 30s;
#开启gzip模块
gzip on;
gzip_min_length 1k;
gzip_http_version 1.1;
gzip_buffers 8 32k;
gzip_comp_level 2; #0-9 默认值为1,值越大压缩率越高,消耗的cpu资源越多,传输量减小
gzip_types text/css application/x-javascript ;
gzip_vary on;
#gzip_static on;
gzip_proxied any;
gzip_disable "MSIE [1-6]\.";
output_buffers 1 32k;
postpone_output 1460;
server {
listen 80 default_server;
access_log off;
server_name _; #default
return 444;
}
#server {
# listen 6428;
# access_log off;
#
# location / {
# index index.html;
# root /data/wwwroot/slb;
# expires 30d;
# }
#
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# root html;
# }
# }
#
include site/*.conf;
}
server {
listen 80;
server_name store-admin-test.nubia.cn;
access_log /tmp/ddd;
location / {
proxy_pass http://localhost:8007;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_redirect off;
proxy_set_header Accept-Encoding ‘gzip‘;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $proxy_add_x_forwarded_for;
#$http_x_forwarded_for;
#$remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Cookie $http_cookie;
#chunked_transfer_encoding off;
}
location ~ ^/(WEB-INF)/ {
deny all;
}
error_page 403 404 500 502 503 504 /error.html;
}
本文出自 “8159085” 博客,谢绝转载!
03.Nginx配置