title: NGINX, FastCGI, UTF-8 Encoding: Output iso-8859-1 instead of utf8
body: <p>i hope you can give me an idea about what's going wrong.</p>
  
  <p>The Szenario:
  I run gitweb (CGI) with a script in fastcgi mode:</p>
  
  <pre><code>#!/bin/sh
  export FCGI_SOCKET_PATH=127.0.0.1:7001
  su git -c "/var/www/vh_[vhost]/htdocs/gitweb.cgi --fastcgi &amp;"
  </code></pre>
  
  <p>Then i use nginx to serve that content:</p>
  
  <pre><code>...
  fastcgi_pass 127.0.0.1:7001; 
  ...
  </code></pre>
  
  <p>Everything works as expected, but here's the problem:</p>
  
  <pre><code>$ wget "http://git.[host].de/?p=[repo].git;a=summary" -O /tmp/test.txt &amp;&amp; file --mime-encoding /tmp/test.txt
  &gt; /tmp/test.txt: iso-8859-1
  
  
  
  $ su git -c "./gitweb.cgi \"?p=[repo].git;a=summary\" &gt; ./test" &amp;&amp; file --mime-encoding ./test 
  &gt; ./test: utf-8
  </code></pre>
  
  <p>Which obviously means that fast-cgi output is utf8 while content served by nginx is iso-8859-1.</p>
  
  <p>FireBugs Response Header:</p>
  
  <pre><code>Server  nginx
  Date    Fri, 02 Sep 2011 14:14:08 GMT
  Content-Type    application/xhtml+xml; charset=utf-8
  Transfer-Encoding   chunked
  Connection  close
  </code></pre>
  
  <p>It looks like the transfer using the socket leads to an encoding problem.<br>
  I've tested a lot but can't figure out how to solve this.</p>