Search code examples
nginxcontent-type

Nginx content-type setting


I have setup webserver(Nginx). and I have deploy applications(charaset:Shift-Jis).

After deploy, accessed to applications But,There is not charset in Nginx returned response "Context-Type" header. Could you teach me Nginx settings it.

I tried the under but it was useless.

Settings

# nginx.conf
server {
  location / {
    proxy_pass http://myapp.com:8080/;
    charset Shift-Jis;
  }
}

Response

# for example (CSS)
・・・
real)content-type: text/css
hope)content-type: text/css; charset=UTF-8
・・・

Best regards.


Solution

  • You are passing the request to a proxy. In this case Headers and Charset are set by the proxy. Set the proper encoding at your Proxy Application. You can override existing charset with: override_charset on;

    charset utf-8;
    override_charset on;
    

    if you want to set the source charset too:

    source_charset koi8-r;