HowTo: Nginx Webserver Send Charset utf-8 Under Unix

I was told that to improve resource download parallelization in IE8 I need to send the character set to the HTTP Content-Type response header. How do I set charset utf-8 under nginx web server running on Unix like operating systems?

Tutorial details
DifficultyEasy (rss)
Root privilegesYes
RequirementsNginx
TimeN/A
You need to use the ngx_http_charset_module. This module provides the specified charset to the “Content-Type” response header field. You can view such header using nothting but standard wget or curl command:

ADVERTISEMENTS


curl -I http://example.com

OR


wget --server-response -O /dev/null http://example.com

How do I enable charset HTTP-header in Nginx?

Open your nginx.conf, enter:
# vi nginx.conf
Append/modify the following directive in http, server, or location:

charset UTF-8;

Save and close the file. Reload the nginx web server, enter:
# /usr/local/nginx/sbin/nginx -s reload

How do I test charset HTTP-header?

Type the following command:
$ wget --server-response -O /dev/null http://www.cyberciti.biz
OR
$ curl -I http://www.cyberciti.biz
Sample outputs:

HTTP/1.1 200 OK
Server: nginx
Date: Mon, 05 Nov 2012 16:42:51 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
X-Whom: l2-com-cyber
Vary: Cookie
Last-Modified: Mon, 05 Nov 2012 16:38:02 GMT
Cache-Control: max-age=311, must-revalidate
X-Galaxy: Andromeda-1
X-Origin-Type: DynamicViaDAL
🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallCentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
1 comment… add one

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.