New in CWP Edge-LatestFree with every CWPpro licenceWebsites up to 300x faster

CWP now includes LSPHP, LSAPI-Cache and CWP Cage at no extra cost with all CWPpro licences. The LSAPI-Cache plugin is integrated into our WordPress and other script installers, and CWP Cage gives every user complete isolation. Available now in the CWP Edge-Latest version.

Get CWPpro ›

htpasswd on CWP

Started by pedromidiasf, October 12, 2025, 09:50:14 PM

Previous topic - Next topic

pedromidiasf

Hi,
Is there a way to add .htpasswd and .htaccess (or configure vhosts to do the same) to the main CWP panel?

I tried to add these files there but they got "Operation not permitted". Also tried to chmod the folder and it got refused.
Is there a way to add them inside this folder or where can i find vhosts of the main panel?

pedromidiasf

#1
Found it!!!

Just needed to add into "/usr/local/cwpsrv/conf/cwpsrv.conf" these 2 lines (inside second "server" into "location /"):
# HTTP Basic Auth
auth_basic "Acesso restrito";
auth_basic_user_file /usr/local/cwpsrv/htdocs/.htpasswd;

Also created a .htpasswd inside the main folder. Probably have to replace that after a CPW update.

Ok cool, now it is required to add a main password before starting using the panel (includes webmail and phpMyAdmin).

PS if you do this, don't forget to restart the service:
sh /scripts/restart_cwpsrv

Take into consideration that everyone will be required to know this password in order to access the panel. In my case there's no other people logging in.

overseer

The FYI for those interested is that cwpsrv runs under Nginx, not Apache -- so syntax for configuration changes needs to be appropriate for Nginx. And thus, .htaccess files are not read or considered.

Also, in order to preserve files through CWP updates, you need to set the immutable bit:
chattr +i /usr/local/cwpsrv/htdocs/.htpasswd

pedromidiasf

Quote from: overseer on October 13, 2025, 01:29:02 AM
The FYI for those interested is that cwpsrv runs under Nginx, not Apache -- so syntax for configuration changes needs to be appropriate for Nginx. And thus, .htaccess files are not read or considered.

Also, in order to preserve files through CWP updates, you need to set the immutable bit:
chattr +i /usr/local/cwpsrv/htdocs/.htpasswd
Yes I fould out. I wasn't familier with Nginx, that's why it wasn't working what I was doing.
Thanks for the immutable bit! This will help!