nginx and auth_basic

后端 未结 3 756
清歌不尽
清歌不尽 2020-12-30 03:09

I am trying to get basic authentication working with nginx in Ubuntu Jaunty. In nginx.conf, I added these two lines under the server context:

server {
   ..         


        
3条回答
  •  佛祖请我去吃肉
    2020-12-30 03:44

    Another gotcha I ran into on bash. Instead of entering my password via prompt I used the -b option of htpasswd to enter the password in-line.

    $ htpasswd -nb admin test123$secure
    

    I couldn't understand why my I kept on running into password mismatch errors, trying different encryption algorithms. I verified with curl that it worked:

    $ curl -u admin:test123$secure https://example.com
    

    Finally, the problem reveiled itself through echo

    $ echo test123$secure
    test123
    

    I made the mistake of using a dolar sign ($) in bash which was interpreted as an empty variable, thus omitting everything else. This can be avoided by dropping the -b option and just using the prompt to enter the password.

提交回复
热议问题