OpenBSD httpd with .htpasswd to subfolders
2021-12-19 · 163 words · 1 min
TagsĀ :  OpenBSD Setup

Maybe not smart, but managed a restricted subfolder with :

:~$ doas cat /etc/httpd.conf
server "domain.se" {
        listen on $WAN tls port 443
        root "/htdocs/domain.se"
        #location "/.htpasswd*" {
        #       block return 403
        #}
        location "/target-sub-folder/*" {
        authenticate with "/auth/domain.se/.htpasswd"
        }
....

Generated the files /var/www/auth & /var/www/auth/domain.se with (550) permission:

:~$ doas ls -la /var/www | grep auth
dr-xr-x---   3 root  www     512 Dec 19 15:52 auth
:~$ doas ls -la /var/www/auth | grep domain.se
dr-xr-x---   2 root  www     512 Dec 19 15:52 domain.se

and the .htpasswd file (htpasswd will ask for a password):

:~$ doas htpasswd /var/www/auth/domain.se/.htpasswd <input username>

with (440) permission.

:~$ doas ls -la /var/www/auth/domain.se/.htpasswd 
-r--r-----  1 www  www  68 Dec 19 15:31 /var/www/auth/domain.se/.htpasswd

Restarting the httpd daemon and this should end in a login/password dialog within the given /target-sub-folder in /etc/httpd.conf.

:~$ doas rcctl -d restart httpd

tech · about · visual · contact · home