下载WINDOWS版本 -- http://nginx.org/en/download.html 下载的是ZIP包,解压到喜欢的目录。html
修改\conf\nginx.conf中的监听端口(listen),改为喜欢的端口,好比8090nginx
进入刚才的目录,使用命令 start nginx 启动nginx服务,访问 http://localhost:8090 进行测试api
#启动nginx服务 start nginx
#不保存退出 nginx -s stop #保存退出 nginx -s quit #重启 nginx -s reload
#配置文件中,第一个server{...}节后,添加一个server节。 #示例访问http://127.0.0.1:8088时,会跳转到 http://localhost/test1 server{ listen 8088; server_name 127.0.0.1; location / { proxy_pass http://localhost/test1; } }
upstream shareapis { server 内网IP1:8011 weight=10; server 内网IP2:8011 weight=10; } server { listen 80; server_name 外网IP; location / { proxy_pass http:// shareapis; } }
location / { root html; index index.html index.htm; } location /dist/ { #root D:/Services/nginx/html; alias D:/Apps/element-starter/dist/; index index.html index.htm; }
发现这里讲的很细:http://jspang.com/post/nginx.htmlbash