Score:0

Ubuntu 22 and Apache protected access

gn flag

I have a website that was set in 2004 with an ISP running Debian. The ISP just jacked up my yearly fees 3x without warning, I am playing around with a Cloud Server running Ubuntu 22.

I haven't played with Linux for more than 25 years and no experience with Ubuntu and setting up servers.

  • Want to set-up an Apache2 Server to run a small hobby website
  • The initial webpage (index.html) is a welcome screen and links to sub-pages and it is not protected
  • The sub-pages are not protected but when you want to download files, you link to a protected webpage via .htacces and .htpasswd

Without a password, the pages are working as expected, all the links are working fine. I just can't make the passwords work. For now I want to just test the Main page with username/passwords

This is my conf file

/etc/apache2/sites-available/mysite.conf

<VirtualHost *:80>

 ServerAdmin [email protected]

 DirectoryIndex index.html

 DocumentRoot /var/www/mysite/

 ServerName mytestsite.com

 ServerAlias www.mytestsite.com

 ErrorLog ${APACHE_LOG_DIR}/error.log

 CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

This is the current .htaccess

/var/www/mysite/.htacces

AuthType Basic

AuthName "Restricted Access to SFP1 Files"

AuthUserFile /etc/apache2/.htpasswd

Require valid user

Require user capun1950

This is the current .htpasswd

/var/www/mysite/.htpasswd

capun1950:$*******$************ (encoded value is false)

So here are my questions

  • is the syntax correctly in the .htaccess file? I see some files with a Directory directive
    <Directory "/www/private">
    
  • Am I missing other steps, or files?
guiverc avatar
cn flag
Ubuntu 22? So you're asking about Ubuntu Core 22 (ie. the *snap* only flavor of Ubuntu 22.04 LTS Server)... 22 & 22.04 are different Ubuntu products don't forget.. *with some different security models used by apps running on them*
John Hanley avatar
in flag
The password file is specified in `.htaccess` as `/etc/apache2/.htpasswd` but your post shows `/var/www/mysite/.htpasswd`. I do not recommend placing `.htpasswd` within the site's directory `/var/www/mysite`. Review this [guide](https://www.digitalocean.com/community/tutorials/how-to-set-up-password-authentication-with-apache-on-ubuntu-20-04). Edit you post after you double-check your OS version.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.