Debian 12.4 Instance on Lightsail using .htaccess and .htpasswd

0

I want to add mandatory authentication using .htaccess and .htpasswd for a folder called 'admin' So, I created an .htaccess file inside the 'admin' folder with the next code

AuthType Basic AuthName "Área Restringida" AuthUserFile /etc/apache2/authfiles/htpasswd-private Require valid-user

The path for the .htaccess file is /var/www/html/admin

The path for the .htpasswd file is /etc/apache2/authfiles/htpasswd-private, and I used the command 'htpasswd -c /etc/apache2/authfiles/htpasswd-private user1' to create the .htpasswd file with a username and password.

After restarting the Apache services, when attempting to access the URL dominio.mx/admin in the browser, the authentication doesn't appear

My question is, do I need to make some configurations or installations for it to work?

질문됨 4달 전154회 조회
2개 답변
0

Hi LauraEquihua,

Depends that you want to use .htaccess files then you need to do:

AllowOverride AuthConfig

or place data into httpd.conf

Below link may help to understand the logic for Apache.

https://httpd.apache.org/docs/2.4/howto/auth.htm

https://www.howtogeek.com/devops/how-to-setup-basic-http-authentication-on-apache/

Thanks,

profile picture
답변함 4달 전
0

Hello,

It looks like the community answer is nearly there but the provided URLs are slightly off.

Here is the correct URL for setting up auth on Apache, specifically the section being referenced regarding enabling authentication directives: https://httpd.apache.org/docs/2.4/howto/auth.html#theprerequisites

Here is further documentation on Apache's AllowOverride configuration directive: https://httpd.apache.org/docs/2.4/mod/core.html#allowoverride

AWS
jscta
답변함 4달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠