windows server nginx 反向代理spring boot配置无效 404 未找到
一个spring boot的系统,开发完成发布到windows服务器里,使用nginx作为反向代理,修改刷新配置文件,nginx.conf,总是报错404。
这个是不生效刷新配置文件的bat脚本:
rem 切换到nginx安装目录 cd d:\nginx-1.25.1\ d: rem 重新加载配置 nginx -s reload pause
考虑可能是没刷新到,还是要全部退出nginx,重启nginx,测试后一切正常。
这个是重启nginx服务bat脚本:
rem 停掉所有nginx程序 taskkill /im nginx.exe /f rem 切换到nginx安装目录 cd d:\nginx-1.25.1\ d: rem 重新启动nginx start nginx rem pause
补充
nginx配置反向代理过程中遇到的坑 配置好之后报404问题
下面补充介绍nginx配置反向代理过程中遇到的坑 配置好之后报404问题
项目场景:
nginx配置反向代理路径
问题描述
在配置nginx反向代理的过程中,路径可以匹配上但是一直报404,找不到路径。nginx配置如下:
location /business { add_header access-control-allow-origin 'http://localhost:8080' always; if ($request_method = 'options') { add_header access-control-allow-origin 'http://localhost:8080'; add_header access-control-allow-headers 'token'; return 204; } proxy_pass http://127.0.0.1:8003; }
请求路径如下:
http://localhost/business/position/list
原因分析:
找了半天,最后发现是 proxy_pass 后面的路径 少写了一个正斜杠
解决方案:
改为下面这个就行了:
location /business { add_header access-control-allow-origin 'http://localhost:8080' always; if ($request_method = 'options') { add_header access-control-allow-origin 'http://localhost:8080'; add_header access-control-allow-headers 'token'; return 204; } proxy_pass http://127.0.0.1:8003/; }
到此这篇关于windows server nginx 反向代理spring boot配置无效 404 未找到的文章就介绍到这了,更多相关nginx 反向代理spring boot配置无效 内容请搜索代码网以前的文章或继续浏览下面的相关文章希望大家以后多多支持代码网!
发表评论