nginx - 非拉丁 HTTP 基本身份验证消息编码/NGINX

标签 nginx encoding character-encoding basic-authentication

我想在浏览器的“HTTP 基本身份验证”提示中显示西里尔文消息,但最终得到的是 abracadabra。

这是我的 NGINX 配置:

server {
  charset utf-8;
  listen 80;
  server_name example.com;
  root /path;
  include snippets/wordpress.conf;
  auth_basic "Введите пароль.";
  auth_basic_user_file /etc/nginx/.htpasswd;
}

这是curl 输出,看起来很漂亮,内容类型字符集为utf-8:

$ curl -I http://example.com/
HTTP/1.1 401 Unauthorized
Date: Sat, 12 Dec 2015 08:37:41 GMT
Content-Type: text/html; charset=utf-8
Connection: keep-alive
Set-Cookie: __cfduid=x; expires=Sun, 11-Dec-16 08:37:41 GMT; path=/; domain=.mydomain.com; HttpOnly
WWW-Authenticate: Basic realm="Введите пароль."
Server: cloudflare-nginx
CF-RAY: xxxxxxxxxxxx-ARN

但这是 Chrome、Safari、Opera、Yandex 浏览器的输出...我能够尝试的每个浏览器:

To view this page, you must log in to this area on example.com:80: ÐведиÑе паÑолÑ.

最佳答案

为了完整性:在关于 serverfault 的新问题中,我发现了这个 answer

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参数是您输入的字符串 auth_basic指示。所以,不能提出任何建议,但坚持使用 ASCII。

关于nginx - 非拉丁 HTTP 基本身份验证消息编码/NGINX,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34238100/

相关文章:

bash - 使用 shell 变量传递选项时,autotools 配置错误

r - twitteR 和 R 的 Twitter 表情符号编码问题

使用 urllib.quote 对字符进行 Python 编码

java - 将包含德语字符的 ANSI 文件转换为 UTF8

java - 为什么 String.endsWith 和 String.startsWith 不一致?

asp.net-mvc - HttpStatusCodeResult 消息编码

c - c语言双向链表使用二级指针有什么好处?

.htaccess - 亚马逊弹性 beantalk : Use nginx/apache to forward subdomains to subfolders

amazon-web-services - Elastic Beanstalk上的HTTPS(Docker多容器)

java - 如何更改 Emma 的 HTML 报告的编码?