开发阶段,前端的服务器是localhost:8080,后端服务器是localhost:8088,涉及跨域,所以用nginx做反向代理使http://localhost:8080/api开头的http请求都转变成http://localhost:8088/api,nginx配置如下
结果一直是404
用postman测试后端接口,显示正常
查看任务管理器,nginx处于运行状态
nginx的访问日志无记录,错误日志也无记录,以下为错误日志最后的内容
不知道到底是哪里出了问题
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
少了一个
/api
根据题主的要求
需要把
http://localhost:8080/api
=>http://localhost:8088/api
但是
实现的是
http://localhost:8080/api
=>http://localhost:8088/
所以需要访问
http://localhost:8080/api/api
才可以访问到真实的 端点.改成
即可
你那个server_name 不是127.0.0.1吗?
localhost
不一定就代表127.0.0.1
吧?