Welcome! Log In Create A New Profile

Advanced

auth_request returns 200 but request overall still returns 401

Posted by Akito 
auth_request returns 200 but request overall still returns 401
September 29, 2022 06:54AM
### `include/pass.conf`
```nginx
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_read_timeout 86400;
proxy_send_timeout 86400;

proxy_buffering off;
proxy_request_buffering off;
proxy_http_version 1.1;
```

### `default` Excerpt
```nginx

....
....
....
set $svc80 "http://my.service:80";
....
....
....

location /auth {
internal;
proxy_pass https://mypublicservice.com/api/auth/;
proxy_pass_request_body off;
proxy_set_header Content-Length "";
#proxy_set_header X-Original-URI $request_uri;
}
....
....
....

location /webdav {
auth_request /auth;
proxy_pass $svc80;
include "include/pass.conf";
}
```

The `/auth` endpoint is **a 100% proven** to return a 200 on authentication. This behaviour is not only tested many times in several ways, but the NGINX log also shows a 200 every single time this endpoint is internally addressed. Therefore, the authentication indubitably works.

However, when a client tries to access `/webdav` the client supposedly receives a 401, which should be impossible.

The whole NGINX config is also proven to work, because everything worked fine before. Then, the `auth_request` directive was added and now the authentication does not work. So, the `/webdav` endpoint and the `proxy_pass` within it, is also **proven** to work.

So, what's wrong with NGINX and how can it be fixed?
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 104
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready