Problem protecting directory in Apache2

I created a simple password file with user and password of user:

htpasswd -c /etc/htpasswd/.htpasswd user

then updated my jenkins site config:

cat /etc/apache2/sites-enabled/jenkins-ssl.conf

DocumentRoot /var/lib/jenkins
ServerName jenkins.example.com

ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all

ProxyPass “/.well-known/acme-challenge” “!”
ProxyPass / http://127.0.0.1:8080/ nocanon
ProxyPassReverse / http://127.0.0.1:8080/
ProxyPassReverse / http://jenkins.example.com/
ProxyPreserveHost On

AllowEncodedSlashes NoDecode
RequestHeader set X-Forwarded-Proto “https”
RequestHeader set X-Forwarded-Port “443”

AllowOverride All Require all granted AuthType basic AuthName "Authorisation required" AuthUserFile "/etc/htpasswd/.htpasswd" Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec Order allow,deny Allow from all

<Location “/”>

Options +FollowSymLinks +Multiviews +Indexes

AllowOverride All

AuthType basic

AuthName “Authorisation required”

AuthUserFile “/etc/htpasswd/.htpasswd”

Require all granted

Require valid-user

Order allow,deny

Allow from all

CustomLog {APACHE_LOG_DIR}/jenkins.access.log combined ErrorLog {APACHE_LOG_DIR}/jenkins.error.log

Possible values include: debug, info, notice, warn, error, crit,

alert, emerg.

LogLevel warn
SSLCertificateFile …fullchain.pem
SSLCertificateKeyFile …privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf

If I un-comment the disabled Location section and comment-out the basic-auth I see the username/password prompt when I restart however the comment is not the one I set and I cannot login.

Does anyone have any idea why this is not working?

Thats a question for StackExchange, not Cloudflare.

2 Likes

That’s not a site I have used. What is the best way to ask a question there?

It is a typical Q&A site (the most prominent example is StackOverflow). Just choose a category and ask the same question.

Ok thanks.