LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 08-12-2018, 06:59 PM   #1
Davno
Member
 
Registered: Mar 2004
Location: Montreal, Canada
Distribution: Linux Mint 18.1 Serena
Posts: 176

Rep: Reputation: 24
Apache2 .htpasswd and 000-default.conf problem


Hi,

I configured Apache2 .htpasswd and 000-default.conf, an restarted the server.

Now i am being asked a password correctly only when i connect through my own LAN Network, but still now protection when i connect from outside my own Wifi.

P.S. I have a domain name registered.

Thxs.
 
Old 08-12-2018, 07:05 PM   #2
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.5
Posts: 1,432

Rep: Reputation: 490Reputation: 490Reputation: 490Reputation: 490Reputation: 490
How are you going outside your LAN?

An .htaccess login will persist until all instances of the browser are closed. Once you login, opening a new tab or window will not require another login. Close all browser windows, then try from outside the LAN first...

Presuming here that you did not let your browser save the login the first time you used it...
 
Old 08-12-2018, 07:20 PM   #3
Davno
Member
 
Registered: Mar 2004
Location: Montreal, Canada
Distribution: Linux Mint 18.1 Serena
Posts: 176

Original Poster
Rep: Reputation: 24
I may not have explain properly

I meant after i thought i configured correctly, i used my cell phone in LTE mode and try to connect to my server.
It did connect but with no password being asked.

Also i did not use .htaccess to configured, i use method #1 from DigitalOcean .htpasswd and 000-default.conf. Option 1: Configuring Access Control within the Virtual Host Definition (Preferred)

Last edited by Davno; 08-12-2018 at 07:25 PM.
 
Old 08-12-2018, 09:18 PM   #4
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.5
Posts: 1,432

Rep: Reputation: 490Reputation: 490Reputation: 490Reputation: 490Reputation: 490
OK
Please post what you added to the config file (yes, it is better to add auth_config to a config file than use .htpasswd)

and please clarify "connect through my own LAN Network" are you doing both the phone connect and that with the domain name?
 
Old 08-12-2018, 10:04 PM   #5
Davno
Member
 
Registered: Mar 2004
Location: Montreal, Canada
Distribution: Linux Mint 18.1 Serena
Posts: 176

Original Poster
Rep: Reputation: 24
Quote:
Originally Posted by scasey View Post
OK
Please post what you added to the config file (yes, it is better to add auth_config to a config file than use .htpasswd)

and please clarify "connect through my own LAN Network" are you doing both the phone connect and that with the domain name?
I do not have access to my server right now, i will post the config tomorrow, but what i meant about Lan Network is that my server is hosted on my own home computer, its not hosted on a Domain Site or ISP, i did get a domain name registered and it is configured properly (Nameserver, Arecord, ect...);

The problem is when i later configured Apache2 .htpasswd and 000-default.conf.

The problem is that it does not ask for a password when other people connect from outside my Network (wifi/router/home server).
But when i try to connect from any computer on the same router than my server, it does ask for a password.

P.S. This is a home server, i am playing with, for friends and family, that is why i want to password the access the www.myservername.com.
 
Old 08-12-2018, 11:00 PM   #6
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.5
Posts: 1,432

Rep: Reputation: 490Reputation: 490Reputation: 490Reputation: 490Reputation: 490
OK. But one thing you're saying is confusing. One uses either .htpasswd or a conf file, not both.
Waiting for you to share what you've actually done.
 
Old 08-13-2018, 05:51 AM   #7
Davno
Member
 
Registered: Mar 2004
Location: Montreal, Canada
Distribution: Linux Mint 18.1 Serena
Posts: 176

Original Poster
Rep: Reputation: 24
Thank you for your patience

Hi,
Ref: This site: https://www.digitalocean.com/communi...n-ubuntu-16-04

I followed Step 1 and 2
Code:
sudo htpasswd -c /etc/apache2/.htpasswd sammy
and Step 3 Option 1
Code:
sudo nano /etc/apache2/sites-enabled/000-default.conf
Code:
<VirtualHost *:80>
  ServerAdmin webmaster@localhost
  DocumentRoot /var/www/html
  ErrorLog ${APACHE_LOG_DIR}/error.log
  CustomLog ${APACHE_LOG_DIR}/access.log combined

  <Directory "/var/www/html">
      AuthType Basic
      AuthName "Restricted Content"
      AuthUserFile /etc/apache2/.htpasswd
      Require valid-user
  </Directory>
</VirtualHost>
Years ago on a previous server i had more success configuring .htaccess as per Option 2 of the same website.
But this time i did not add an .htaccess file in /var/www/html.

Last edited by Davno; 08-13-2018 at 05:54 AM.
 
Old 08-13-2018, 09:21 AM   #8
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.5
Posts: 1,432

Rep: Reputation: 490Reputation: 490Reputation: 490Reputation: 490Reputation: 490
That all looks absolutely correct to me...
 
1 members found this post helpful.
Old 08-13-2018, 10:05 AM   #9
Davno
Member
 
Registered: Mar 2004
Location: Montreal, Canada
Distribution: Linux Mint 18.1 Serena
Posts: 176

Original Poster
Rep: Reputation: 24
Quote:
Originally Posted by scasey View Post
That all looks absolutely correct to me...
Yes i think so.
But since it does not work, ill try configuring with option 2: .htaccess.

Thank you for your help.
 
Old 08-13-2018, 11:03 AM   #10
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.5
Posts: 1,432

Rep: Reputation: 490Reputation: 490Reputation: 490Reputation: 490Reputation: 490
Are you sure your phone hasn't cached the site? Can you clear the web cache on your phone?
Do you have any other way to test from outside your LAN?
Again, are you using the domain name from within your LAN? (not the IP address)

If you want to email me the domain name, I'd be happy to report what happens from here.
 
Old 08-13-2018, 08:11 PM   #11
Davno
Member
 
Registered: Mar 2004
Location: Montreal, Canada
Distribution: Linux Mint 18.1 Serena
Posts: 176

Original Poster
Rep: Reputation: 24
Works now

Hi,

I had friends connecting to my server from there home and still it was not asking for a password, so i revert my configuration 000-default.conf back to default and use methode # 2 creating an .htaccess file and modifying apache2.conf instead of editing 000-default.conf.
It's not the prefered option but option # 1 did not work for some reason.
I work nice now

Thxs.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How to write the rewrite rule in /etc/apache2/apache2.conf? luofeiyu Linux - Server 1 09-20-2015 08:11 AM
[SOLVED] Default apache2 /sites-available/000-default and apache2.conf nobuntu Linux - Server 3 02-06-2013 11:05 AM
Apache2 - disable default virtual hosts problem mcc28 Linux - Server 5 08-17-2012 09:27 AM
Should I include srm.conf in httpd.conf in apache2? xpucto Linux - Software 3 02-16-2006 08:16 AM
saving changes to apache2/conf/httpd.conf file Zaius Linux - Newbie 6 01-09-2004 11:45 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 11:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration