nginx.conf 配置详情:
#user nobody;
worker_processes 1;
error_log logs/error.log;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
client_max_body_size 2048m; # 设置最大上传限制为5G
proxy_buffer_size 1024m; # 设置代理缓冲区大小为128k
proxy_buffers 4 1024m; # 设置代理缓冲区块数和块大小
client_body_timeout 6000s; # 用户连接超时时间,单位是秒
client_header_timeout 6000s; # 指定获取整个请求头的超时时间
proxy_connect_timeout 6000s; # nginx用于处理请求的超时时间
proxy_read_timeout 6000s; # nginx读取上游服务器响应时间
proxy_send_timeout 6000s; # nginx向上游服务器写客户端请求的超时时间
keepalive_timeout 6000s; # nginx打开 keepalive 连接最大时间
send_timeout 6000s; # nginx发送给客户端响应的超时时间
sendfile on;
upstream v1_server {
server 192.168.1.1:8080 down; # 不参加负载均衡
# 当检查后端服务3次失败(每1秒检查一次),判定后端服务不可用,然后60秒内不再检查。
server 192.168.1.254:8700 max_fails=3 fail_timeout=600s;
server 192.168.2.208:8700 backup; # 备份节点,在所有提供服务节点均不可用时启用
}
server {
listen 8100;
server_name yuming.test.com;
location / {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET,POST,DELETE';
add_header 'Access-Control-Allow-Header' 'Content-Type,*';
index index.html index.htm;
client_max_body_size 2048m;
}
location /output.tar.gz/ {
return 403;
}
location ~ \.(ini|conf|txt|gz)$ {
deny all;
}
location /v1/ {
proxy_pass http://v1_server;
}
}
upstream v2_server {
server 192.168.1.1:8080 down; # 不参加负载均衡
server 192.168.1.254:8100 max_fails=3 fail_timeout=600s;
server 192.168.2.208:8100 backup; # 备份节点,在所有提供服务节点均不可用时启用
}
server {
listen 8200;
server_name yuming2.test.com;
location / {
root html/yuming2;
index index-stable.html;
client_max_body_size 1024m;
}
location /v1/ {
proxy_pass http://v2_server;
client_max_body_size 1024m;
}
error_page 404 /index-stable.html;
}
}
配置内容: