I have set the charset to 'utf-8' in the nginx.conf file under the http
directive. It looks like this:
http {
charset utf-8;
}
I have two server directives. One for example.com, and one for www.example.com. They look like this.
server {
listen 80;
server_name example.com;
root /usr/share/nginx/html;
return 301 http://www.example.com$request_uri;
}
server {
listen 80;
server_name www.example.com;
root /usr/share/nginx/html;
index index.html;
location /{
try_files $uri $uri/ =404;
}
}
However, an initial request to example.com
does not seem to present the charset type after the Content-Type
HTTP header. Here are the response headers:
$ curl example.com -I --progress-bar
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Thu, 10 Jul 2014 05:10:42 GMT
Content-Type: text/html
Content-Length: 178
Connection: keep-alive
Location: http://www.example.com/
$ curl www.example.com -I --progress-bar
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 10 Jul 2014 05:13:30 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 123
Last-Modified: Tue, 08 Jul 2014 00:55:38 GMT
Connection: keep-alive
ETag: "53bb418a-7b"
Accept-Ranges: bytes
Why isn't the charset being set in the non-www server?