在nginx文件下的nginx-1.18.0\conf下的nginx.conf文件中server的内容为
server {
listen 8090; //代理接口
server_name 127.0.0.1; //代理服务IP
location / {
proxy_pass http://127.0.0.1:8080; //本地项目访问IP
proxy_redirect default;
}
location /loc {
rewrite ^/loc/(.*)$ /$1 break; //代理请求接口要替换掉截止的地方
proxy_pass http://www.jiekou.com/; //后台接口IP
}
}
然后启动nginx
访问项目使用代理的http://127.0.0.1:8090;
请求数据使用
url:"http://127.0.0.1:8090/loc/"+接口名