版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/shiheyingzhe/article/details/86549075
#user nobody;
worker_processes 1; #设置为cpu core的个数
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024; #最大连接数
#use epoll;
}
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"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 60s;
#tcp_nopush on;
#tcp_nodelay on;
client_max_body_size 500m;
client_body_timeout 120s;
proxy_buffer_size 256k;
proxy_buffers 32 32k;
proxy_busy_buffers_size 256k;
#gzip on;
upstream favresin{
#在max_fails次转发给对应服务器失败以后,等待fail_timeout秒的时间再次发送
server 172.16.0.16:5000 max_fails=5 fail_timeout=30;
server 172.16.0.19:5001 max_fails=5 fail_timeout=30;
keepalive 256; #保持http连接的数量,不在会话结束后立即结束连接
#fair;
}
server {
listen 80;
server_name 172.16.0.255; #从外部接受请求并转发给其他服务器的ip地址
client_max_body_size 500m;
client_body_timeout 120s;
keepalive_timeout 60s;
#tcp_nopush on;
#sendfile on;
#itcp_nodelay on;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
client_body_timeout 120s;
client_max_body_size 500m;
proxy_http_version 1.1; #http版本和keepalive对应
proxy_set_header Connection "";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_pass http://favresin; #接受请求的机器地址
root html;
keepalive_timeout 60s;
#tcp_nopush on;
#sendfile on;
#tcp_nodelay on;
proxy_read_timeout 190s;
proxy_send_timeout 120s;
#index index.html index.htm;
#client_body_buffer_size 256k;
# proxy_connect_timeout 1s;
proxy_buffer_size 256k;
proxy_buffers 32 32k;
proxy_busy_buffers_size 256k;
#proxy_temp_file_write_size 256k;
#proxy_next_upstream error timeout invalid_header http_500 http_503 http_404;
#proxy_max_temp_file_size 128m;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
参考的内容:https://www.cnblogs.com/piscesLoveCc/p/5867900.html
http://www.cnblogs.com/wang-meng/p/5861174.html
https://blog.csdn.net/qq_33135813/article/details/82827720
https://www.cnblogs.com/wzjhoutai/p/6932007.html