您的位置:首页 > 运维架构 > Nginx

nginx安装(Windows)入门实例简介

2012-08-06 11:10 567 查看
nginx [engine x]是Igor Sysoev编写的一个HTTP和反向代理服务器,

另外它也可以作为邮件代理服务器。

下面简单介绍一下nginx实现网站负载均衡测试的例子.

1,下载nginx http://nginx.net/
我用的是nginx-1.2.2,解压到C:\nginx-1.2.2

2,修改niinx的conf文件

在server {上面一行加入下面的内容:

upstream  mytest123.com {

  server   147.151.240.234:8080;

  server   147.151.241.151:8080;

}

147.151.240.234和147.151.241.151是nginx反向代理的两台web server.

修改在server {里面下面的内容

location / {

    root   html;

    index  index.html index.htm;

}

改为:

location / {

    proxy_pass http://test.com/;
    proxy_redirect default;

}

改完后的配置如下

    upstream  mytest123.com {

      server   147.151.240.234:8080;

      server   147.151.241.151:8080;

    }

    server {

        listen       80;

        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        #location / {

        #    root   html;

        #    index  index.html index.htm;

        #}

        location / {

            proxy_pass http://test.com/;
            proxy_redirect default;

        }

3,测试,在localhost的IE地址栏输入 localhost会发现http请求会

均衡到代理的两台web server.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息