专业网站建设品牌,十四年专业建站经验,服务6000+客户--广州京杭网络
免费热线:400-683-0016      微信咨询  |  联系我们

swagger.net 使用nginx 代理时出现端口号导致出错

当前位置:网站建设 > 技术支持
资料来源:网络整理       时间:2023/2/14 1:07:25       共计:3648 浏览

1:当我们通过nginx代理访问时,由于nginx配置了映射到的一个站点为端口为127.0.0.1:6201,导致访问swagger接口时出现增加端口号,如下截图,这样就导致整个swagger无法使用。

2:这个问题网上找了很多没找到方法,主要是自己英语太差了,没注意看到注释内容,可以配置一个固定的url地址用于 代理/负载均衡  。

	
  1. var thisAssembly = typeof(SwaggerConfig).Assembly;
  2. GlobalConfiguration.Configuration
  3. .EnableSwagger(c =>
  4. {
  5.  
  6. c.IncludeXmlComments(GetXmlCommentsPath());
  7. c.IncludeXmlComments(System.String.Format(@"{0}\bin\KJ.Model.XML", System.AppDomain.CurrentDomain.BaseDirectory));
  8.  
  9. // By default, the service root url is inferred from the request used to access the docs.
  10. // However, there may be situations (e.g. proxy and load-balanced environments) where this does not
  11. // resolve correctly. You can workaround this by providing your own code to determine the root URL.
  12. //
  13. if (IsRelease())
  14. {
  15. c.RootUrl(req => "https://xxx");
  16. }
版权说明:
本网站凡注明“广州京杭 原创”的皆为本站原创文章,如需转载请注明出处!
本网转载皆注明出处,遵循行业规范,如发现作品内容版权或其它问题的,请与我们联系处理!
欢迎扫描右侧微信二维码与我们联系。
·上一条:nginx代理访问swagger | ·下一条:解决 asp.net core swagger nginx 代理服务器转发后,无法访问的问题 Swashbuckle

Copyright © 广州京杭网络科技有限公司 2005-2025 版权所有    粤ICP备16019765号 

广州京杭网络科技有限公司 版权所有