1.核心配置nginx.conf
user nobody nobody;
worker_processes auto;
pid /data/logs/tengine/tengine.pid;
worker_rlimit_nofile 65535;
worker_connections 65535;
##########################HTTP SETTINGS#########################
http {
default_type application/octet-stream;
server_names_hash_bucket_size 256;
client_header_buffer_size 256k;
large_client_header_buffers 4 256k;
client_max_body_size 250m;
check_shm_size 5m;
client_body_buffer_size 512k;
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" '
'"$gzip_ratio" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for" '
# '"$gzip_ratio" '
access_log /data/logs/tengine/access.log access;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
server_tokens off;
server_info off;
######################FASTCGI SETTINGS#########################
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
fastcgi_intercept_errors on;
######################GZIP SETTINGS#########################
gzip on;
gzip_proxied any;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_vary on;
########## PROXY SETTINGS ###################
proxy_ignore_client_abort on;
proxy_connect_timeout 600;
proxy_read_timeout 600;
proxy_send_timeout 600;
proxy_buffer_size 128k;
proxy_buffers 8 128k;
proxy_busy_buffers_size 256k;
proxy_temp_file_write_size 512k;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#open_file_cache max=204800 inactive=20s;
#open_file_cache_min_uses 1;
#proxy_temp_path /dev/shm/nginx_tmp;
#limit_req_zone $binary_remote_addr zone=req_ip:10m rate=30r/m;
#geo $limited{
# default 1;
# 218.85.126.250/32 0;
# 27.154.34.22/32 0;
#}
#map $limited $limit {
# 1 $binary_remote_addr;
# 0 "";
#}
#limit_req_zone $limit zone=foo:10m rate=10r/s;
################
req_status_zone server "$host" 20M;
req_status server;
#req_status_zone_add_indecator server $response_fbt_time;
#req_status_zone_add_indecator server $2xx_bytes_sent;
#####################VHOSTS SETTINGS#########################
geo $maintenance {
default 1;
127.0.0.1 0;
}
###########################
geo $white_ip {
127.0.0.1-127.0.0.255 1;
}
map $http_x_forwarded_for $clientRealIp {
"" $remote_addr;
~^(?P<firstAddr>[0-9\.]+),?.*$ $firstAddr;
}
limit_req_whitelist geo_var_name=white_ip geo_var_value=1;
limit_req_log_level error;
limit_req_zone $clientRealIp $uri zone=qps:10m rate=2r/s;
limit_req_zone $uri zone=url:10m rate=1r/s;
#limit_req_zone $binary_remote_addr zone=one:10m rate=10r/s;
#limit_req_zone $binary_remote_addr zone=one:10m rate=10r/s;
#limit_req_zone $binary_remote_addr $request_uri zone=three:10m rate=10r/s;
##########################
#include blacklist.conf;
geo $clientRealIp $blacklist {
default 0;
include blacklist.conf;
}
###########################
###########################
include vhost/*.conf;
}
#stream {
# # 佐~N端彌~G佐~Q 80
# upstream stream_backend_http {
# server 223.96.95.25;
# }
#
# #佐~N端彌~G佐~Q 443
# upstream stream_backend_https {
# server 223.96.95.25:443;
# }
#
# server {
# listen 80;
# server_name test.victorydeng.com;
# proxy_pass stream_backend_https;
# }
#
# server {
# listen 443;
# server_name love.victorydeng.com;
# proxy_pass stream_backend_https;
# }
#}
2.上游服务配置upstream.conf
upstream arbit {
session_sticky;
server 100.134.1.4:8085;
#server 100.134.1.5:8085;
check interval=3000 rise=2 fall=5 timeout=5000 type=http;
check_http_send "HEAD /index.html HTTP/1.0\r\n\r\n";
check_http_expect_alive http_2xx;
}
upstream basicGateway {
session_sticky;
server 100.134.1.4:8084;
#server 100.134.1.5:8084;
check interval=3000 rise=2 fall=5 timeout=5000 type=http;
check_http_send "HEAD /index.html HTTP/1.0\r\n\r\n";
check_http_expect_alive http_2xx;
}
upstream basicGateway-room {
#session_sticky;
consistent_hash $uri;
#hash $request_uri;
server 100.134.1.4:8084;
#server 100.134.1.5:8084;
check interval=3000 rise=2 fall=5 timeout=5000 type=http;
check_http_send "HEAD /index.html HTTP/1.0\r\n\r\n";
check_http_expect_alive http_2xx;
}
upstream basicGateway-chatRoom {
#session_sticky;
consistent_hash $uri;
#hash $request_uri;
server 100.134.1.4:8084;
#server 100.134.1.5:8084;
check interval=3000 rise=2 fall=5 timeout=5000 type=http;
check_http_send "HEAD /index.html HTTP/1.0\r\n\r\n";
check_http_expect_alive http_2xx;
}
upstream mastiff {
session_sticky;
server 100.134.1.4:8086;
#server 100.134.1.5:8086;
check interval=3000 rise=2 fall=5 timeout=5000 type=http;
check_http_send "HEAD /index.html HTTP/1.0\r\n\r\n";
check_http_expect_alive http_2xx;
}
upstream panda {
session_sticky;
server 100.134.1.4:8087;
#server 100.134.1.5:8087;
check interval=3000 rise=2 fall=5 timeout=5000 type=http;
check_http_send "HEAD /index.html HTTP/1.0\r\n\r\n";
check_http_expect_alive http_2xx;
}
upstream userGateway {
session_sticky;
server 100.134.1.4:8089;
#server 100.134.1.5:8089;
check interval=3000 rise=2 fall=5 timeout=5000 type=http;
check_http_send "HEAD /index.html HTTP/1.0\r\n\r\n";
check_http_expect_alive http_2xx;
}
upstream pigeons {
session_sticky;
server 100.134.1.4:8095;
#server 100.134.1.5:8095;
check interval=3000 rise=2 fall=5 timeout=5000 type=http;
check_http_send "HEAD / HTTP/1.0\r\n\r\n";
check_http_expect_alive http_2xx;
}
upstream chat {
session_sticky;
server 100.134.1.4:8090;
#server 100.134.1.5:8090;
check interval=3000 rise=2 fall=5 timeout=5000 type=http;
check_http_send "HEAD / HTTP/1.0\r\n\r\n";
check_http_expect_alive http_2xx http_4xx;
}
upstream commander {
session_sticky;
server 100.134.1.4:8091;
check interval=3000 rise=2 fall=5 timeout=5000 type=http;
check_http_send "HEAD / HTTP/1.0\r\n\r\n";
check_http_expect_alive http_2xx http_4xx;
}
upstream consultancy {
session_sticky;
server 100.134.1.4:8092;
#server 100.134.1.5:8092;
check interval=3000 rise=2 fall=5 timeout=5000 type=http;
check_http_send "HEAD / HTTP/1.0\r\n\r\n";
check_http_expect_alive http_2xx http_4xx;
}
upstream message {
session_sticky;
server 100.134.1.4:8094;
#server 100.134.1.5:8094;
check interval=3000 rise=2 fall=5 timeout=5000 type=http;
check_http_send "HEAD / HTTP/1.0\r\n\r\n";
check_http_expect_alive http_2xx http_4xx;
}
upstream referee {
session_sticky;
server 100.134.1.4:8096;
#server 100.134.1.5:8096;
check interval=3000 rise=2 fall=5 timeout=5000 type=http;
check_http_send "HEAD / HTTP/1.0\r\n\r\n";
check_http_expect_alive http_2xx http_4xx;
}
upstream user {
session_sticky;
server 100.134.1.4:8097;
#server 100.134.1.5:8097;
check interval=3000 rise=2 fall=5 timeout=5000 type=http;
check_http_send "HEAD / HTTP/1.0\r\n\r\n";
check_http_expect_alive http_2xx http_4xx;
}
upstream storage {
session_sticky;
#server 100.134.1.4:8098;
server 100.134.1.5:8098;
check interval=3000 rise=2 fall=5 timeout=5000 type=http;
check_http_send "HEAD / HTTP/1.0\r\n\r\n";
check_http_expect_alive http_2xx http_4xx;
}