#user nobody;
#配置启动进程
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
#配置连接数
}
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 65;
#gzip on;
#配置server权重
server localhost:6060 weight=5;
server localhost:7070 weight=2;
server localhost:8080 weight=3;
}
#按hash分配权重
upstream casserver {
ip_hash;
server 192.168.199.70:7011 max_fails=1 fail_timeout=600s;
server 192.168.199.70:7012 max_fails=1 fail_timeout=600s;
server 192.168.199.71:7011 max_fails=1 fail_timeout=600s;
server 192.168.199.72:7012 max_fails=1 fail_timeout=600s;
check interval=3000 rise=2 fall=5 timeout=1000 type=http;
}
#限制ip访问
listen 80 default;
server_name _;
return 500;
}
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location /cas {
proxy_connect_timeout 30;
proxy_send_timeout 300;
proxy_read_timeout 300;
proxy_pass http://casserver/cas;
proxy_set_header Host $host:80;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
}
本文详细介绍了Nginx服务器的配置方法,包括进程配置、连接数设置、上传文件大小限制等核心参数调整,并深入探讨了负载均衡策略及代理设置。
1万+

被折叠的 条评论
为什么被折叠?



