解决服务器部署Nginx后不能访问Swagger

1,895 阅读1分钟

提供2中方法,优先选择第一种

(1) .yml 配置文件中直接添加配置

springfox:
  	documentation:
    	swagger:
      		v2:
        		host: ip:8080

(2) Nginx代理转发swagger-ui.html相关路径

location /swagger-ui.html {
    proxy_pass http://ip:port;
    index  index.html index.htm;
}

location /webjars {
	proxy_pass http://ip:port;
    index  index.html index.htm;
}

location /swagger-resources {
  proxy_pass http://ip:port;
  index  index.html index.htm;
}

location /v2 {
  proxy_pass http://ip:port;
  index  index.html index.htm;
}