Skip to content

Deploy springdoc in subdirectory returns 404 #1434

@soasada

Description

@soasada

I'm serving a Spring Boot application behind a nginx as reverse proxy, it is served in a subdirectory (let's say "/subdir"). The API is working correctly, but when I visit "https://example.com/subdir/swagger-ui/index.html" it returns the index.html correctly with a 200 HTTP OK, but is not able to find all of the static files that the index.html is pointing to: https://example.com/subdir/swagger-ui/swagger-ui.css for instance. In the other hand, if I try to visit "https://example.com/subdir/v3/api-docs/swagger-config" it also works.

  • What version of spring-boot you are using? 2.6.2
  • What modules and versions of springdoc-openapi are you using? 1.6.3

I'm using:

server.forward-headers-strategy=framework
server.tomcat.redirect-context-root=false

in my application.properties.

And this is my nginx config:


location /subdir/ {
                proxy_pass http://127.0.0.1:8080/;
                proxy_redirect off;
                proxy_buffer_size 128k;
                proxy_buffers 4 256k;
                proxy_busy_buffers_size 256k;

                proxy_set_header Host $http_host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-Proto https;
                proxy_set_header X-Forwarded-Prefix $http_x_forwarded_prefix;
                proxy_set_header X-Forwarded-Host $http_x_forwarded_host;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-NginX-Proxy true;

                proxy_set_header X-Forwarded-Protocol https;
                proxy_set_header X-Forwarded-Ssl on;
                proxy_set_header X-Url-Scheme https;
}

What am I missing?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions