Answer the question
In order to leave comments, you need to log in
How to make a custom authorization page in Nginx using the "auth_request" or "auth_basic" function?
Hello colleagues.
The task is to make a custom authorization page on the Nginx web server using the " auth_request " or " auth_basic " function. Is this even possible or am I delusional and wasting my time?
As planned:
I have a domain, for example my.domain.com , in order to open it, you need to log in to this web server, i.e. you need to configure auth_basic , and this is done very simply, no more than 5 minutes. That is, we will create a password file using the htpasswd utility and simply add this to the virtual host config:
auth_basic "Restricted Content";
auth_basic_user_file /etc/nginx/.htpasswd;
server {
listen 80;
server_name my.domain.com;
# При открытии сайта, запрашивает авторизацию на веб-сервере nginx
location / {
auth_request /auth;
...
}
# Говорим серверу что путь к авторизации ( /auth) находится тут, по ссылке http://login.domain.com:
location = /auth {
proxy_pass http://login.domain.com;
proxy_pass_request_body off;
proxy_set_header Content-Length "";
proxy_set_header X-Original-URI $request_uri;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question