nginx 简单使用

一,下载

http://nginx.org/en/download.html

这个是我下载的windows版本

二,解压后目录

三,修改配置文件

(由于80端口很可能被 SQL Server Reporting Service 占用了,所以我们修改一下)

打开conf文件夹中的nginx.conf文件

upstream test中配置了站点的服务器。

listen改成8001,这个是nginx的启动端口

location中配置了就是  http://test;     (test就是上面的upstream test)

PS:如果session有混乱情况,则添加   

proxy_hide_header Set-Cookie;

举例:

server {
        listen       8001;
        server_name  test
        location / {
            proxy_pass http://test;
        proxy_hide_header Set-Cookie;
        }
}

四,启动nginx

直接目录下 cmd运行,nginx.exe

退出时,切记去任务管理器查看一下,有的话手动结束,不然配置文件不更新。

下面是常用命令。

nginx -s quit         退出nginx  
nginx -s reload     重启并载入nginx.conf
nginx -s reopen     打开日志
nginx -v            版本  
nginx -t            检查nginx.conf
nginx -h            帮助

五,测试

我访问了  http://localhost:8001/test/test.do

看一下结果,说明是轮流访问的。

原文地址:https://www.cnblogs.com/hanjun0612/p/11543845.html