windows7下配置nginx

1,下载 nginx-1.2.9 2,解压,D:/soft/nginx-1.2.9 3,启动:start nginx,停止:nginx -s stop,重新加载配置:nginx -s reload, 退出:nginx -s quit 4,打开conf下的nginx.conf 第一种,配置配置一台电脑 server { #监听的端口号 listen 80; #ip地址或者主机名字 server_name 192.168.1.35; charset UTF-8; access_log logs/host.access.log main location / { index index.html index.htm; #root D:/soft/nginx-1.2.9/jedis-2.0.0-javadoc; #默认的是nginx安装目录的html目录下的index.html root html; } location ~ ^/ndtracker { #默认的是main.jsp或者index.html或者index.htm index main.jsp index.html index.htm; proxy_pass http://192.168.1.35:8080; }

备注:ndtracker 项目名称
            启动jetty或者tomcat服务器,ip地址栏输入http://192.168.1.35/ndtracker即可访问,无需再加端口号8080。

粘贴主要代码第二种负载均衡:
upstream ndtracker {
    #weight 参数表示权值,权值越高被分配到的几率越大
    server 192.168.1.108:8080     max_fails=3 fail_timeout=60s weight=2;       
    server 192.168.1.35:8080 max_fails=3 fail_timeout=60s weight=2;       
}
server {
#监听的端口号
    listen       80;
#ip地址或者主机名字
    server_name  192.168.1.35;
    charset UTF-8;
    access_log  logs/host.access.log  main;
    location / {
        index      	index.html index.htm; 
        #root          D:/soft/nginx-1.2.9/jedis-2.0.0-javadoc;
    #默认的是nginx安装目录的html目录下的index.html
    root 	        html;
    }
location /ndtracker {
    #默认的是main.jsp或者index.html或者index.htm
        index      main.jsp index.html index.htm;
        proxy_pass http://ndtracker;
    }
    
    负载均衡,代理。

转载于:https://my.oschina.net/momisabuilder/blog/304052

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值