What is the right encoding/charset in nginx configuration file to display accentuated characters in HTTP authentication message ?

For example, this conf file :

server {
    location / {
        auth_basic           "Zone sécurisée";
        auth_basic_user_file .htpasswd;

Is displaying in Firefox' prompt window :

"Zone sécurisée"

No real solution or explanation found on the web. I tried to replace é in conf file by é, by &, by &#233, by =C3=A9 or adding charset utf-8 directive or =?UTF-8? at the beginning of the string but nothing works !

Official nginx doc, talking about a "string" without more explanation about encoding of accentuated characters.

NB : I have no problem with similar .htaccess file for Apache

  • Did you check that your editor actually saves the files in UTF8 encoding? – Sven Jul 10 '17 at 13:10
  • Yes, it saved in UTF-8 and I tried UTF-8 with BOM but it worst ! – Klemart3D Jul 10 '17 at 13:39

RFC 7617 Section 3

The 'realm' parameter carries data that can be considered textual; however, `[RFC7235] does not define a way to reliably transport non- US-ASCII characters. This is a known issue that would need to be addressed in a revision to that specification.

realm parameter is the string you put in auth_basic directive. So, can't suggest anything, but stick to ASCII.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.