Unable use `/api-docs` or any path, result a 301 / 404 / ERR_CONNECTION_REFUSED . Is a reserved endpoint?

Hi

We are unable to use /api-docs path as it redirect to, eg. http://host:8080/api-docs.
As you know, by default, [API] create entrypoint on port 8080 for API.

After some tests, I have this cases:

  1. [API] enabled + URI: /api-docs => redirect to http://host:8080/api-docs.
  2. [API] enabled + URI /api-docs/ => OK, pass to Nginx container (notice the / from end of uri).
  3. [API] disabled + URI: /api-docs => error, connection dropped.
  4. [API] enabled + custom entrypoint for api (port 8888) + URI: /api-docs => error, connection dropped.

We need /api-docs in order to rewrite it to /api-docs/. But look like is part of / reserved for core.

Any workaround for this?

Thanks.

Hello,

could you give more information about your configuration?

FYI /api-docs is not a reserved endpoint.

Hi,

@ldez indeed, is not a reserved endpoint.
After couple of tests on a cloned container, I was able to trace the issue.

Nothing to do with Traefik, as is related to Nginx.
In v.1.11.8 directive absolute_redirect on; has been introduced:
http://nginx.org/en/docs/http/ngx_http_core_module.html#absolute_redirect

It work fine if you use Nginx with standard ports:

server {
    listen 80 default;
    ...
    server_name your-domain.com;
    ....
    location / {
        index index.html index.php;
        try_files $uri $uri/ /index.php;
    }

Traefik GET http://your-domain.com/api-docs
return 301 header:
location: http://your-domain.com/api-docs/ <--- OK

BUT

Using non-80 port, http only and catch-all server_name:

server {
    listen 8080 default;
    ...
    # catch-all # server_name your-domain.com;
    ....
    location / {
        index index.html index.php;
        try_files $uri $uri/ /index.php;
    }

Traefik GET http://your-domain.com/api-docs
return 301 header:
location: http://nginx-container-name:8080/api-docs/ <--- here browser crash

because of absolute_redirect on; this translate to:
$schema://$hostname:$port/$uri/

After turn that off, it just use relative path /api-docs/ (ending in trailing slash). All good.

Personally, I'm surprised that this is happening because I only use:

        try_files $uri $uri/ /index.php;

This try_files directive should do internal check/redirects at nginx level, as docs said:
http://nginx.org/en/docs/http/ngx_http_core_module.html#try_files

Anyway, sorry for false alarm. Will check this on Nginx community.

Regards,