Nginx 的配置

上一篇 / 下一篇  2008-10-20 15:12:08 / 个人分类:linux

测试环境: 2台不同IP上面的tomcat服务器。

实现目标:配置nginx来访问http://mytest,分别访问的是192.168.192.200:8080和192.168.192.201:8080两台服务器。

配置文件内容:

user  nobody nobody;
worker_processes  1;

pid        logs/nginx.pid;

events {
    use epoll;
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;      
  
    sendfile        on;
    keepalive_timeout  65;


    upstream mytest{
              server 192.168.192.200:8080 weight=1;
              server 192.168.192.201:8080 weight=1;
    }

    server {
        listen       80;
        server_name  192.168.192.200;

        location / {
           proxy_pass     http://mytest;
            root   html;
            index  index.jsp index.html index.htm;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

    }
}

 

(红色部分是修改的主要内容,这只是配置的1种方法,其他的方法还没测试,所以暂时只写这种。)


TAG: linux

引用 删除 zhulanyyzl   /   2009-12-02 17:15:36
weight没有就色织,相当于为0个,所以在访问的时候分配就自然不能到200那台机器上。之后设置了,就能通过比例是1:1的情况进行分配并访问服务器
^.^旋^.^ 引用 删除 peixuan   /   2008-10-20 15:19:37
很奇怪,当我还没设置weight值的时候,我访问http://mytest只能访问到201那台服务器的,不知道是不和因为我200那台tomcat是和apache整合的原因呢?但是我设置了weight值后,就都可以正常的访问了,也几乎是按1:1的次数访问的。有高手知道原因的麻烦留言告诉我哦,先谢啦~!
 

评分:0

我来说两句

我的栏目

日历

« 2024-04-25  
 123456
78910111213
14151617181920
21222324252627
282930    

数据统计

  • 访问量: 12902
  • 日志数: 14
  • 建立时间: 2007-11-10
  • 更新时间: 2008-11-18

RSS订阅

Open Toolbar