编辑nginx配置文件:
upstream test_backend {
server 127.0.0.1:8080 fail_timeout=0;
server 192.168.5.100:8080 fail_timeout=0;
server 192.168.5.102:8080 fail_timeout=0;
}
server {
listen 80;
server_name www.test.com;
root /home/ubuntu/workspace/group_demo/public;
try_files $uri/index.html $uri.html $uri @user1;
location @user1 {
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Real-Ip $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_forwarded_for;
proxy_buffering on;
proxy_pass http://test_backend;
}
location ~ ^(/assets) {
access_log off;
expires max;
}
}
访问www.test.com测试