下载安装Nginx(windows),配置Nginx反向代理
一、 下载安装Nginx
- 官网下载
官网:http://nginx.org/en/download.html
- 编写nginx一键启动bat,也可以直接点击nginx.exe
@echo off
## 如果启动前已经启动nginx并记录下pid文件,会kill指定进程
nginx.exe -s stop
## 测试配置文件语法正确性
nginx.exe -t -c conf/nginx.conf
## 显示版本信息
nginx.exe -v
## 按照指定配置去启动nginx
nginx.exe -c conf/nginx.conf
- 启动,访问http://localhost(nginx默认80端口)看看是否正确启动
二、配置反向代理
- 编辑conf/nginx.conf(nginx的配置文件)
server {
listen 9003;
server_name ip; // ip为代理的名字,一般会写:ip地址,例如:192.168.*.*
location {
proxy_pass http://192.168.*.*:*; // 添加dialing的IP地址和端口
}
}
- 重新启动,访问重试