Skip to content

Commit

Permalink
#111 Added proxy settings for BASIC authentication. (#117)
Browse files Browse the repository at this point in the history
* #111 Added proxy settings for BASIC authentication.

* #111 Fix White Space.
  • Loading branch information
kght6123 authored Sep 1, 2024
1 parent cd0d5bf commit a31e840
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions pages/blog/2023-10-29_basic_auth.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,29 @@ server {
proxy_pass http://127.0.0.1:3080;
}

#...except for /api/, which will use LibreChat's own auth system
#...except for /api/, which will use LibreChat's own auth system
location ~ ^/api/ {
auth_basic off;
include /config/nginx/proxy_params.conf;
proxy_pass http://127.0.0.1:3080;
}

#...except for manifest, Manifests are excluded because browsers cannot read them if BASIC authentication is enabled.
location /manifest.webmanifest {
auth_basic off;
proxy_pass http://127.0.0.1:3080;
}

#...except for health check, Avoid the phenomenon of repeatedly requesting BASIC credentials in health checks. Note in particular that Safari has a bug in storing BASIC credentials.
location /health {
auth_basic off;
proxy_pass http://127.0.0.1:3080;
}
}
```

The provided Nginx configuration sets up a server block for `librechat.domain.com`:

1. **Basic Auth for All Requests**: The `location /` block sets up Basic Auth for all requests to `librechat.domain.com`. The `auth_basic` directive activates Basic Auth, and the `auth_basic_user_file` directive points to the file containing valid usernames and passwords.

2. **Exception for `/api/` Endpoint**: The `location ~ ^/api/` block matches any URL path starting with `/api/`. For these requests, Basic Auth is turned off using `auth_basic off;`. This ensures that LibreChat's own authentication system can operate without interference.
2. **Exception for `/api/` Endpoint**: The `location ~ ^/api/` block matches any URL path starting with `/api/`. For these requests, Basic Auth is turned off using `auth_basic off;`. This ensures that LibreChat's own authentication system can operate without interference.

0 comments on commit a31e840

Please sign in to comment.