Nginx gives an Internal Server Error 500 after I have configured basic auth

前端 未结 11 2775
盖世英雄少女心
盖世英雄少女心 2020-12-16 11:29

I am trying to do basic auth on Nginx. I have version 1.9.3 up and running on Ubuntu 14.04 and it works fine with a simple html file.

Here is the html file:

相关标签:
11条回答
  • 2020-12-16 11:59

    I was running Nginx in a Docker environment and I had the same issue. The reason was that some of the passwords were generated using bcrypt. I resolved it by using nginx:alpine.

    0 讨论(0)
  • 2020-12-16 11:59

    Do you want a MORE secure password hash with nginx basic_auth? Do this:

    echo "username:"$(mkpasswd -m sha-512) >> .htpasswd
    

    SHA-512 is not considered nearly as good as bcrypt, but it's the best nginx supports at the moment.

    0 讨论(0)
  • 2020-12-16 11:59

    In my case, I was using plain text password by -p flag, and coincidentally my password start with $ character. So I updated my password and thus the error was gone.

    NB: Other people answer helped me a lot to figure out my problem. I am posting my solution here if anyone stuck in a rare case like me.

    0 讨论(0)
  • 2020-12-16 12:00

    Well, just use correct RFC 2307 syntax:

    passwordvalue          = schemeprefix encryptedpassword
    schemeprefix           = "{" scheme "}"
    scheme                 = "crypt" / "md5" / "sha" / altscheme
    altscheme              = "x-" keystring
    encryptedpassword      = encrypted password
    

    For example: sha1 for helloworld for admin will be * admin:{SHA}at+xg6SiyUovktq1redipHiJpaE=

    I had same error cause i wrote {SHA1} what against RFC syntax. When i fixed it - all worked like a charm. {sha} will not work too. Only correct {SHA}.

    0 讨论(0)
  • 2020-12-16 12:02

    I just had the same problem - after checking log as suggested by @Drazen Urch I've discovered that the file had root:root permissions - after changing to forge:forge (I'm using Forge with Digital Ocean) - the problem went away.

    0 讨论(0)
提交回复
热议问题