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

来源:互联网 发布:南京网络教育 编辑:程序博客网 时间:2024/05/16 03:31
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.