为iredadmin添加密码保护 - Basic Authentication
现象:将nginx的Basic Authentication配置内容,添加到/etc/nginx/templates/iredadmin.tmpl页头或页尾,不起作用。
尝试:调整位置,可以Basic Authentication的配置内容添加到/etc/nginx/templates/iredadmin.tmpl文件中的python配置里。
如:
# Python scripts
location ~ ^/admin(.*) { # <- Changed
rewrite ^/admin(/.*)$ $1 break; # <- Changed
include /etc/nginx/templates/hsts.tmpl;
include uwsgi_params;
uwsgi_pass unix:/run/uwsgi/iredadmin.socket;
uwsgi_param UWSGI_CHDIR /var/www/iredadmin;
uwsgi_param UWSGI_SCRIPT iredadmin;
uwsgi_param SCRIPT_NAME /admin; # <- Changed
auth_basic "Administrator’s Area";
auth_basic_user_file /etc/apache2/.htpasswd;
# Access control
#allow 127.0.0.1;
#allow 192.168.1.10;
#allow 192.168.1.0/24;
#deny all;
}
参考:
- https://serverfault.com/questions/388326/unable-to-correctly-configure-nginx-with-http-auth-on-a-sub-directory-for-uwsgi
- https://docs.iredmail.org/iredadmin-pro.custom.base.url.html
- https://forum.iredmail.org/topic15206-basic-http-authentication-on-httpmydomaincomiredadmin.html
- https://docs.nginx.com/nginx/admin-guide/security-controls/configuring-http-basic-authentication/