将一个Spring boot工程部署到生产环境, 配置nginx
server {
listen 80;
server_name ops.foo.com;
location / {
proxy_pass http://127.0.0.1:8086;
proxy_set_header X-Real-IP $remote_addr;
}
}
浏览器中访问: ops.foo.com, 选中某一接口点击try it out, 什么都没发生, 显示No Content。
Request URL
http://127.0.0.1:8086/doSomething
并不是
http://ops.foo.com/doSomething
通过搜索找到如下的解决方法
可以在启动工程时显式添加这么一个系统属性
-Dspringfox.documentation.swagger.v2.host=ops.shicaiguanjia.com
或者显式在配置文件(application.properties)中进行配置
参考文档:
https://github.com/springfox/springfox/issues/764