美文网首页
mac nginx安装配置 tomcat负载均衡

mac nginx安装配置 tomcat负载均衡

作者: YHWXQ简简单单的生活 | 来源:发表于2018-02-01 15:54 被阅读61次

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

    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负载均衡

          本文链接:https://www.haomeiwen.com/subject/uqidzxtx.html