美文网首页
Nginx Windows快速开始

Nginx Windows快速开始

作者: jumper996 | 来源:发表于2019-08-23 18:17 被阅读0次

1.安装Nginx

1.1 下载nginx

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

image.png
1.2 解压缩
image.png
1.3 启动一下
image.png
image.png
1.4 测试运行

打开 http://localhost/

2. 配置请求转发

2.1 编辑conf目录下的nginx.conf
image.png
image.png
2.2 我们配置个demo为例,现在访问路径为http://localhost:8080
image.png
2.3 我这里将 http://localhost/test转到 http://localhost:8080
image.png
2.4 重启新加载配置
// 测试配置是否正确
nginx -t
// 重新加载配置文件
nginx -s reload
image.png
2.5 我们继续访问http://localhost/test ,貌似成功了,但是资源文件找不到,可以说失败了
image.png
2.6 我们来该一下项目发布根路径,增加font_end下发布
image.png
2.7 再来修改nginx配置,增加font_end
location /test {
    proxy_pass http://localhost:8080/font_end/;
}
2.8 重启新加载配置
// 测试配置是否正确
nginx -t
// 重新加载配置文件
nginx -s reload
2.9 貌似还是没找到啊
image.png
2.10 思考一下,是因为请求转发过去了,但是资源没有转发过去。

原因是我选择了发布路径是font_end所以nginx也应该是配置这个,改下test成font_end


image.png
2.11 重启新加载配置
// 测试配置是否正确
nginx -t
// 重新加载配置文件
nginx -s reload

转发成功


image.png

相关文章

网友评论

      本文标题:Nginx Windows快速开始

      本文链接:https://www.haomeiwen.com/subject/mjmtectx.html