nginx负载均衡一则

 


#user nobody;
worker_processes 2;
events {
# 最大并发数
worker_connections 1024;
}
http{
# 待选服务器列表
upstream list{
#ip_hash;
server 172.17.30.1 fail_timeout=60s;
server 172.17.30.2;
server 172.17.30.3;
}

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"'
'$upstream_addr '
'ups_resp_time: $upstream_response_time '
'request_time: $request_time';
#access_log logs/access.log main;
access_log /var/log/nginx/access.log main;

server{
# 监听端口
listen 80;
# 根目录下
location / {
# 选择哪个服务器列表
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header host $host;
proxy_pass http://list;
}

}

server{
# 监听端口
listen 443 ssl;
add_header X-Frame-Options SAMEORIGIN;
ssl_certificate cert/test.pem;
ssl_certificate_key cert/test.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
# 根目录下
location / {
# 选择哪个服务器列表
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header host $host;
proxy_pass http://list;
}


}


发表评论

邮箱地址不会被公开。 必填项已用*标注


*