nginx配置远程web页面请求本地service

2018-12-25  本文已影响0人  得鹿梦为鱼

场景

前后端分离的工程,前端页面基本可用,后端人员需在本地测试一些接口。

如果使用postman进行测试,可能没有在页面上操作方便。

解决

使用nginx进行代理。

test-web 是项目的web地址;

test 是后端工程的context-path。

配置截图

    location /test-web {

           proxy_pass  http://remote-ip:port/test-web;

            index  index.html index.htm;

    }

    location /test {

            proxy_pass  http://localhost-ip:port;

     }

使用

在浏览器输入 localhost/test-web ,就像在开发环境上进行操作是一样的。但是页面请求的后台服务地址将会是你本地启动的server。

上一篇 下一篇

猜你喜欢

热点阅读