Not signed in (Sign In)
    • CommentAuthorefiplus
    • CommentTimeApr 2nd 2008
     permalink
    I have setup an nginx-php fastcgi environment successfully but there are still a few glitchesto curb.

    A directive has been set from /etc/nginx/sites-enabled/default to password protect /phpmyadmin/ as follows:

    location = /phpmyadmin/ {
    auth_basic "Acceso Restringido";
    auth_basic_user_file /path/to/htpasswd;
    }

    The actual restriction is being enforced and the username/password data is validated.

    However, instead of loading the dir, it displays a 404 error page, though the URL is correct.
    If i comment out the restriction directive, the directory loads just fine.

    Have doubled checked for typos and did not find any inconsistency.

    Regards,
    Nuno.
    • CommentAuthormovielady
    • CommentTimeApr 2nd 2008
     permalink

    I think it should be:

    location /phpmyadmin {

    not what you have above. :) (I’ve got a restricted directory set up like that and it works just fine.)

    • CommentAuthorefiplus
    • CommentTimeApr 2nd 2008
     permalink
    have

    <blockquote><cite>Posted By: movielady</cite><p>I think it should be:</p><p><code>location /phpmyadmin {</code></p><p>not what you have above. :) (I’ve got a restricted directory set up like that and it works just fine.)</p></blockquote>

    I have tried that in the 1st place.
    Same error output.

    Nuno.
    • CommentAuthorrob
    • CommentTimeApr 2nd 2008
     permalink
    You might need to set a 'root' directive inside the location /phpmyadmin/ block.
    Thankful People: efiplus
    • CommentAuthormovielady
    • CommentTimeApr 2nd 2008 edited
     permalink

    Ok, here’s a stupid question (but it never hurts to ask, right? ::g::): do you have the htpasswd file created, and is it named just htpasswd, not .htpasswd? I ran up against that (the picky file name thing) the other day.

    • CommentAuthorefiplus
    • CommentTimeApr 2nd 2008
     permalink
    <blockquote><cite>Posted By: movielady</cite><p>Ok, here’s a stupid question (but it never hurts to ask, right? ::g::): do you have the htpasswd file created, and is it named just<b>htpasswd</b>, not<b>.htpasswd</b>? I ran up against that (the picky file name thing) the other day.</p></blockquote>

    No offense taken :)
    Yes, i have the file in the proper place and with the proper name.
    It actually seems to authenticate just fine, though for some strange reason it is retrieving a 404 error.
    • CommentAuthorefiplus
    • CommentTimeApr 2nd 2008
     permalink
    Posted By: robYou might need to set a 'root' directive inside the location /phpmyadmin/ block.


    And how would the block look like?
    • CommentAuthorefiplus
    • CommentTimeApr 2nd 2008
     permalink
    Looks like this is a path issue...

    2008/04/02 19:02:22 [error] 20680#0: *17 open() "/usr/local/nginx/html/phpmyadmin" failed (2: No such file or directory), client: 83.165.206.13, server: 209.20.65.31, URL: "/phpmyadmin", host: "209.20.65.31"

    Probably i will have to specify
    location /var/www/phpmyadmin instead of /phpmyadmin

    Interesting.

    Nuno.
    • CommentAuthormovielady
    • CommentTimeApr 2nd 2008 edited
     permalink

    location /phpmyadmin { auth_basic "Acceso Restringido"; auth_basic_user_file /path/to/htpasswd; root /path/to/web/site/and/main/phpmyadmin; }

    or whatever the main phpmyadmin page name is. But I wouldn’t think you’d need to have the root directive there if it’s working in the regular location /phpmyadmin block already, just not with the authentication.

    Hmm.

    Thankful People: efiplus
    • CommentAuthorefiplus
    • CommentTimeApr 2nd 2008
     permalink
    Got it :)

    location = /phpmyadmin {
    root /var/www;
    auth_basic "Acceso Restringido";
    auth_basic_user_file /path/to/htpasswd;
    }

    Thank you all.
    Nuno.
    Thankful People: vincew, MindTooth
    • CommentAuthormovielady
    • CommentTimeApr 2nd 2008
     permalink

    Yay!

    Out of curiosity, are you trying to make the restriction work for all vhosts you get set up by putting it in the default configuration?

    • CommentAuthorefiplus
    • CommentTimeApr 2nd 2008
     permalink
    Posted By: movielady

    But I wouldn’t think you’d need to have the root directive there if it’s working in the regular location /phpmyadmin block already, just not with the authentication.

    Hmm.

    Thankful People:efiplus


    Well, adding the root directive has saved the day.

    Just for the record, i am running nginx 0.6.3 on Ubuntu 7.10.

    Nuno.
    • CommentAuthorefiplus
    • CommentTimeApr 3rd 2008
     permalink
    Posted By: movielady

    Yay!

    Out of curiosity, are you trying to make the restriction work for all vhosts you get set up by putting it in the default configuration?



    Nope.
    There are no multiple vhosts on this particular box.
    It will serve one single site.

    Nuno.
    • CommentAuthorefiplus
    • CommentTimeApr 5th 2008
     permalink
    Nginx is a weird animal...

    location = /phpmyadmin {
    root /var/www;
    auth_basic "Acceso Restringido";
    auth_basic_user_file /path/to/htpasswd;
    }


    does not restrict /phpmyadmin/

    Do i have to clone the current directive and add a trailing / to /phpmyadmin or does Nginx accept * wildcards?

    Nuno.
    • CommentAuthorrob
    • CommentTimeApr 5th 2008
     permalink
    Try replacing your location = .. line with:

    location ~ ^/phpmyadmin(/)?$ {
    • CommentAuthorefiplus
    • CommentTimeApr 5th 2008
     permalink
    Posted By: robTry replacing your location = .. line with:

    location ~ ^/phpmyadmin(/)?$ {


    This is driving me nuts.
    The rule you endorse generates a strange 403 error after authenticating (meaning that it actually authenticates).
    To make it all more odd, my previous rule is now also leading to a 403 page.

    Puzzling.

    Nuno.
    • CommentAuthormovielady
    • CommentTimeApr 6th 2008
     permalink

    The info about the location directive on the English wiki says that the equal sign in the location section makes it only work when the url matches the exact pattern given, in your case “/phpmyadmin” – so I would think that you either need to drop the equal sign in the location declaration location /phpmyadmin or, as you said, clone the current directive you have and change the location directive to location = /phpmyadmin/

    Just a guess. :)