码迷,mamicode.com
首页 > 其他好文 > 详细

nginx 配置反向代理和负载均衡

时间:2018-10-07 11:01:59      阅读:192      评论:0      收藏:0      [点我收藏+]

标签:.com   pre   load   http   监听   index   nginx安装   加载   com   

Nginx的配置文件:

nginx安装目录/conf/nginx.conf

重新加载配置文件

./nginx -s reload

配置虚拟主机

一个server就是一台虚拟主机

 server {
        listen       80;//监听端口
        server_name  localhost;//域名

        location / {
            root   html;
            index  index.html index.htm;
        }
 }

反向代理与负载均衡

upstream tomcat {
    server ip1:端口号1 weight=2;
    server ip2:端口号2 weight=2;//权重
}
 server {
        listen       80;//监听端口
        server_name  www.test.com;//域名

        location / {
            proxy_pass   http://tomcat2;
            index           index.html index.htm;
        }
 }

nginx 配置反向代理和负载均衡

标签:.com   pre   load   http   监听   index   nginx安装   加载   com   

原文地址:https://www.cnblogs.com/-saligia-/p/9749527.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!