mac nginx安装配置 tomcat负载均衡

安装
1.终端执行:
brew search nginx
brew install nginx
2./usr/local/etc/nginx/nginx.conf (配置文件路径)
3.Nginx 默认8080端口,这时已经可以访问了:
localhost:8080
会有一个默认欢迎界面。

mac nginx安装配置 tomcat负载均衡_第1张图片
image

4.命令
nginx -c /usr/local/etc/nginx/nginx.conf
nginx -s quit
负载均衡配置
http下配置
upstream tomcat_servers
{
#ip_hash;
server 192.168.7.200:8080 weight=10;
server 192.168.7.137:8080 weight=5;
}
server下配置
location / {
root html;
index index.html index.htm;
proxy_redirect off;
proxy_pass http://tomcat_servers;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_connect_timeout 60;
proxy_send_timeout 60;
proxy_read_timeout 60;
}

你可能感兴趣的:(mac nginx安装配置 tomcat负载均衡)