Skip to content

Instantly share code, notes, and snippets.

@yangvipguang
Last active March 3, 2019 08:08
Show Gist options
  • Save yangvipguang/6cba15517d1507f99c4440637a9c6134 to your computer and use it in GitHub Desktop.
Save yangvipguang/6cba15517d1507f99c4440637a9c6134 to your computer and use it in GitHub Desktop.
Nginx.conf
user nginx;
worker_processes 4;
worker_cpu_affinity 0001 0010 0100 1000;
error_log /etc/nginx/logs/error_nginx.log crit;
pid /run/nginx.pid;
worker_rlimit_nofile 51200;
events {
use epoll;
worker_connections 51200;
multi_accept on;
}
http {
include mime.types;
default_type text/plain;
log_format main '$geoip_country_name $server_name $remote_addr - $remote_user [$time_local] "$request" '
'$status uptream_status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" '
'$ssl_protocol $ssl_cipher $upstream_addr $request_time $upstream_response_time';
server_names_hash_bucket_size 128;
#########Buffers######################
client_header_buffer_size 1k;
client_body_buffer_size 10K;
large_client_header_buffers 2 1k;
client_max_body_size 128M;
########Timeout######################
keepalive_timeout 15;
send_timeout 12;
client_body_timeout 12;
client_header_timeout 12;
sendfile on;
tcp_nopush on;
server_tokens off;
tcp_nodelay on;
########Gzip##########################
gzip on;
gzip_buffers 16 8k;
gzip_comp_level 6;
gzip_http_version 1.1;
gzip_min_length 256;
gzip_proxied any;
gzip_vary on;
gzip_types
text/xml application/xml application/atom+xml application/rss+xml application/xhtml+xml image/svg+xml
text/javascript application/javascript application/x-javascript
text/x-json application/json application/x-web-app-manifest+json
text/css text/plain text/x-component
font/opentype application/x-font-ttf application/vnd.ms-fontobject
image/x-icon;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
open_file_cache max=1000 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 2;
open_file_cache_errors on;
proxy_connect_timeout 300;
proxy_read_timeout 300;
proxy_send_timeout 300;
proxy_buffer_size 4k; ##等同于系统单个内存页面大小(getconf PAGE_SIZE)
proxy_buffering on;
proxy_buffers 320 4k; ## number size (size 同上)
proxy_busy_buffers_size 128k; ## 设置为proxy_buffers 两倍
proxy_temp_file_write_size 128k;
proxy_temp_path /etc/nginx/proxy_temp;
proxy_cache_path /etc/nginx/proxy_cache levels=1:2 keys_zone=content:20m inactive=1d max_size=100m loader_threshold=300 loader_files=200 ;
################# new upstream ################
upstream zabbix {
ip_hash;
server 127.0.0.1:8888 weight=1 max_fails=2 fail_timeout=5s; ##Zabbix
}
upstream jumpserver {
ip_hash;
server 127.0.0.1:8080 weight=1 max_fails=2 fail_timeout=5s;
}
upstream jenkins {
ip_hash;
server 127.0.0.1:8181 weight=1 max_fails=2 fail_timeout=5s;
}
upstream redmine {
ip_hash;
server 127.0.0.1:9999 weight=1 max_fails=2 fail_timeout=5s;
}
########################## vhost #############################
include /etc/nginx/conf/sites-enabled/*.conf;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment