htaccess / htpasswd

Discussion in 'Plesk 7.0 Installation and 'How Do I' Questions' started by levrah, Nov 5, 2004.

  1. levrah

    levrah Mega Poster

    Messages:
    120
    Can someone post instructions on manually protecting a directory please? (including the htaccess, htpasswd and any other files I might need to create plus any special security "heads-up" I might need to be aware of in doing this)

    I need to protect a directory under cgi-bin, which means I cannot use Plesk's built-in Protect Directory function.

    Thanks in Advance!
    -mike
     
  2. levrah

    levrah Mega Poster

    Messages:
    120
    I figured it out. Here's a brief how-to for others who might need to know:

    This is a 3-step process
    1) Create password file with assigned username and password:
    SSH into the box
    htpasswd -c /FULL_DIRPATH/PASSWORD_FILENAME USERNAME
    (you will be asked to type the password in next (and confirm it))
    (NOTE: "-c" creates the file (removes old if one exists))
    (NOTE: To add more users to the same file, don't use "-c")
    2) Create .htaccess file in the directory that needs to be protected
    Create with vi on the box (or with a text editor then upload via ftp)
    File contents:
    AuthType Basic
    AuthName "LOGIN BOX TEXT"
    AuthUserFile /FULL_DIRPATH/PASSWORD_FILENAME
    Require user USERNAME
    3) Restart httpd
    service httpd restart
    ##################################################
     
  3. exothermic

    exothermic Mega Poster

    Messages:
    153
    I don't think this will work for dirs outside of cgi since you need a line in your vhost.conf that would say something like

    Allow Override

    or something like that I don't remember the exact syntax, http://httpd.apache.org for more info
     
  4. Not Wroking

    This is just not working for me anyone have any ideas on how to get this running.
     
  5. exothermic

    exothermic Mega Poster

    Messages:
    153
    did you follow his instructions, and add the line to your vhost.conf?
     
  6. vhost.conf

    I can even find that file on my server. I did a search for it on the drive but could find it. I will look for it again. What am I suppose to change exactlly.
     
  7. exothermic

    exothermic Mega Poster

    Messages:
    153
    look in the docs for vhost.conf It should talk about it there, If not I know it is explained in multiple places in the forums. The file is created by you.
     
  8. User Created file.

    Ohh.. that would explain why I cant find it... cause I never made such a file and I havent a clue how to or where to put it. Now what files do I read to learn how to make and were to put it.
     
  9. exothermic

    exothermic Mega Poster

    Messages:
    153
  10. Docs no Help

    There is no straight forward information except that non fuctional password protection option offered in Plesk in the docs. That option doesnt work for subdomains at all or atleast thier is no detail information on how to make it work.
     
  11. exothermic

    exothermic Mega Poster

    Messages:
    153
    That information was pertaining to vhost.conf, and how to impliment it, not password dirs dirrectly.
     
  12. Reviewing again

    I have search serveral thread none of them are written in a manner that assists a noivce user to Plesk and windows servers. Very poor documentation if you have no clue were to start.
     
  13. exothermic

    exothermic Mega Poster

    Messages:
    153
    The dirrections listed above are actually apache dirrections and have nothing to do with plesk. If you are having trouble with them you might want to ask on the apache mailing list. The only part that plesk will play is if you have to turn on access to .htaccess files for a dir. You do this by adding a line to the server apache config by inserting it into the vhost.conf file. This file goes in the /vhostname/conf/vhost.conf Then you have to reload the configs by

    /usr/local/psa/admin/sbin/websrvmng -ra

    The contents of the vhost.conf file will be specified by these docs

    http://httpd.apache.org/docs-2.0/mod/core.html#allowoverride

    Again the only part of this that might, and I say might because .htaccess maybe turned on by default, be anywhere related to plesk is the vhost.conf. After that it becomes a apache issue, which surprisingly enough is not cover comprehensively in the plesk manual. But how to add dirrectives to the http.include file is.
     
  14. levrah

    levrah Mega Poster

    Messages:
    120
    Just a heads-up for those who might not realize it.

    Plesk's built-in directory protect function should be used -- if for no other reason than ease and convenience - if you need to protect directories in the web root or the ssl web root (e.g. /httpdocs/ and /httpsdocs/). It's great for that, but...

    Since I needed to protect a directory under /cgi-bin/ -- which is not under /httpdocs/ explicitly, except by symlink -- I had to figure a way to do it manually.

    The instructions I posted are the result, and they are for protecting directories that cannot be done easily within Plesk's built-in directory protect function. It uses .htaccess and the htpasswd command-line command (which requires access to the box). The htpasswd command creates the password file -- which you can name anything you want, although most people use .htpasswd (w/the dot in front).

    Hope the clarification helps.

    In short, if protecting directories under /httpdocs/ or /httpsdocs/, use Plesk. Otherwise, the instructions posted previous should help.

    -mike
     
  15. exothermic

    exothermic Mega Poster

    Messages:
    153
    Also a side note I don't believe you can protect dirs in subdomains using plesk interface. Another reason to use .htaccess
     
  16. levrah

    levrah Mega Poster

    Messages:
    120
    True True -- Good point
     
  17. Still Not Working

    Ok. I got the file htaccess and htpaswd on the sever and properly configured, Plesk's Apache server is not reading the file. Now I am getting allthe talk about a vhost.conf file so that the file is read by Apache run in a windows enviorment. I am Admin for this server so I have remote desktop access to this box, and the command line.

    I see all this talk about setting httpd.conf file to see the vhost.conf file but nothig point me to were to find info one actually doing it.
     

Share This Page