The title pretty much sums it up, we have a very simple virtual host setup in nginx protected by basic auth, so it looks like that:

server {
listen       portnumber;
server_name  *.domain.com;
location / {
     root   /var/www/mywebsite.com;
     index  index.html index.htm;
     auth_basic "Restricted";                                #For Basic Auth
     auth_basic_user_file /etc/nginx/.htpasswd;  #For Basic Auth

When I visiting say aaa.domain.com, or domain.com or any of it's subdomains it will ask for the authentication credentials if I didnt previously authenticated on this (sub)domain, so the question is: can I share authentication session between all the domains of the same virtual host in nginx, so if I successfully authenticated on one of them I wont be asked to type the login and password on any other again while the session is valid?

Maybe it is possible to (re)implement basic auth in some scripting language supported by nginx, could you please give any advice on an implementation then?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.