nginx修改默认首页,且转发对应请求
下载nginx
https://nginx.org/en/download.html
这里是windows版本 nginx-1.25.2
下载zip包解压丢到D盘,修改配置
D:\nginx-1.25.2\conf\nginx.conf
修改监听端口,修改默认网页
复制你的前端网页到html文件夹内,修改root节点的默认首页
监听相对路径并转发
location /XXXX.Api.Login/ { proxy_pass http://192.168.1.X:8038/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location /XXXX.Api.Admin/ { proxy_pass http://192.168.1.X:8038/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location /XXXX.Api.File/ { proxy_pass http://192.168.1.X:7877/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; }
保存文档,启动nginx.exe
如果要频繁修改配置文件,用命令行到D:\nginx-1.25.2,输入下面命令确定即可重载配置
.\nginx -s reload