下载安装

官方下载链接http://nginx.org/en/download.html,下载稳定版本
图片说明
下载到压缩包后直接压缩,然后双击nginx.exe即可启动
图片说明
任务管理器中可以看到是否启动成功

常用命令

  • 启动 start nginx
  • 查看配置是否正确 nginx -t -c conf/nginx.conf
  • 快速关机 nginx -s stop
  • 优雅的关机 nginx -s quit
  • 重新加载配置文件 nginx -s reload
  • 重新打开日志文件 nginx -s reopen

配置反向代理

/nginx/conf/nginx.conf/修改

    server {
        listen       1234;
        server_name  localhost;
        location / {
           proxy_pass http://127.0.0.1:8088;
           index  index.html index.htm index.jsp;
        }
    }

即把1234端口转发到8888端口,访问1234端口就相当于访问到8888端口的服务端程序,Node示例如下

var express = require('express')
var app = express()
app.get('/',(req,res,next)=>{
    res.end('hello world')
})
app.listen(8088,()=>{
    console.log('app run')
})

图片说明
成功!