title: spring boot swagger2 behind nginx proxy - swagger-resources not found
body: <p>My pom:</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;io.springfox&lt;/groupId&gt;
      &lt;artifactId&gt;springfox-swagger2&lt;/artifactId&gt;
      &lt;version&gt;2.9.2&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;io.springfox&lt;/groupId&gt;
      &lt;artifactId&gt;springfox-swagger-ui&lt;/artifactId&gt;
      &lt;version&gt;2.9.2&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>and swagger config file</p>
  
  <pre><code>@Configuration
  @EnableSwagger2
  @EnableWebMvc
  @Profile("stage")
  public class SwaggerConfig {
      @Bean
      public Docket api() {
          HashSet&lt;String&gt; protocols = new HashSet&lt;&gt;();
          protocols.add("http");
          protocols.add("https");
          return new Docket(DocumentationType.SWAGGER_2)
                  .protocols(protocols)
                  .select()
                  .apis(RequestHandlerSelectors.any())
                  .paths(PathSelectors.any())
                  .build()
                  .pathMapping("/");
      }
      @Bean
      public WebMvcConfigurer webMvcConfigurer()
      {
          return new WebMvcConfigurer()
          {
              @Override
              public void addResourceHandlers( ResourceHandlerRegistry registry )
              {
                  registry.addResourceHandler( "swagger-ui.html" ).addResourceLocations( "classpath:/META-INF/resources/" );
                  registry.addResourceHandler( "/webjars/**" ).addResourceLocations( "classpath:/META-INF/resources/webjars/" );
              }
          };
      }
  }
  </code></pre>
  
  <p>When I access /swagger-ui.html on my workstation everything works but when I run this project on stage environment where I have nginx proxy with settings:</p>
  
  <pre><code>location ~ ^/(swagger|webjars|configuration|swagger-resources) {
    proxy_pass https://backend;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
  }
  </code></pre>
  
  <p>My swagger page is loading but got alert</p>
  
  <blockquote>
    <p>Unable to infer base url. This is common when using dynamic servlet
    registration or when the API is behind an API Gateway. The base url is
    the root of where all the swagger resources are served. For e.g. if
    the api is available at <a href="http://example.org/api/v2/api-docs" rel="nofollow noreferrer">http://example.org/api/v2/api-docs</a> then the
    base url is <a href="http://example.org/api/" rel="nofollow noreferrer">http://example.org/api/</a>. Please enter the location
    manually:</p>
  </blockquote>
  
  <p>When I am inspecting network requests made i can find that backend returned 404 Not found for
  /swagger-resources/configuration/security</p>
  
  <p>/swagger-resources</p>
  
  <p>/swagger-resources/configuration/ui</p>
  
  <p>any hint?</p>