Results 1 to 7 of 7

Thread: Setting up basic auth on Apache

  1. #1
    Join Date
    Mar 2011
    Location
    Boston Area
    Beans
    3
    Distro
    Ubuntu 11.04 Natty Narwhal

    Setting up basic auth on Apache

    I am to create a part of my site to require a password. Upon research, I have created my .htpasswd file and modified my httpd.conf. When accessing the /admin section (the part I want to secure) no password is asked.

    attached is my httpd.conf, I am not using .htaccess.
    #================================================= =======================
    <Directory />
    Options Indexes Includes FollowSymLinks MultiViews
    AllowOverride AuthConfig
    Order allow,deny
    Allow from all
    </Directory>


    <Directory /admin>
    # Begin password protection #
    AuthName "Login"
    AuthBasicProvider file
    Require valid-user
    AuthUserFile "/home/roger/.htpasswd"
    AuthType Basic
    # End password protection #
    </Directory>

  2. #2
    Join Date
    Aug 2010
    Location
    hole
    Beans
    399
    Distro
    Ubuntu

    Re: Setting up basic auth on Apache

    i would go with other settings such as:

    Code:
                     AllowOverride All
    and in the .htaccess file of the specific directory use:
    Code:
    AuthType Basic
    AuthName "Restricted Area: By Invitation Only"
    AuthUserFile /home/www/1111
    AuthGroupFile /dev/null
    
    #AuthGroupFile /usr/local/apache/passwd/groups
    #Require group GroupName
    
    Require valid-user

  3. #3
    Join Date
    Jun 2010
    Location
    Vienna
    Beans
    109
    Distro
    Xubuntu 12.10 Quantal Quetzal

    Re: Setting up basic auth on Apache

    it's crucial that the apache process has permission to read the AuthUser file.

    your file /home/roger/.htpasswd sounds not readable by default

  4. #4
    Join Date
    Mar 2011
    Location
    Boston Area
    Beans
    3
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: Setting up basic auth on Apache

    @elico
    Changing my httpd.conf file and adding the .htaccess file you provided does nothing. I am never prompted for the user/pass, the page loads right away.

    @dapperdanny77
    I set the permissions for the file to 0777, did't work. I moved it to /var/www/ as well and it didnt work

  5. #5
    Join Date
    Nov 2005
    Location
    Bordeaux, France
    Beans
    11,297
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Setting up basic auth on Apache

    <Directory> blocks contain the full path of the directory in question in the filesystem, so you want something like /var/www/mysite and /var/www/mysite/admin.
    「明後日の夕方には帰ってるからね。」


  6. #6
    Join Date
    Jun 2010
    Location
    Vienna
    Beans
    109
    Distro
    Xubuntu 12.10 Quantal Quetzal

    Re: Setting up basic auth on Apache

    check out the <Location> directive instead of <Directory>

    http://httpd.apache.org/docs/current....html#location

    <Location> refers to URLs not to Directories in filesystem

  7. #7
    Join Date
    Mar 2011
    Location
    Boston Area
    Beans
    3
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: Setting up basic auth on Apache

    Quote Originally Posted by dapperdanny77 View Post
    check out the <Location> directive instead of <Directory>

    http://httpd.apache.org/docs/current....html#location

    <Location> refers to URLs not to Directories in filesystem
    THANK YOU! It worked,

    I put a location /admin tag in the httpd.conf file and it works!

    Solved

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •