How to change Content-type in apache or nginx


Good time of the day.

There is Trac, there is a need to change the project list page from simple html to xml. This xml will be assigned an xsl template, no problem here.

The template is written, everything is generated great, but the problem arises that trac renders the response in this way: req.send(output, 'text/html') .

How can you change this content-type to text / xml? Otherwise, the browser does not apply the xsl transformation, you need text / xml.

Before the apache is nginx, which makes proxy_pass to the apache.

In fact, you only need to change the content-type for one path, namely / trac.

A chunk of httpd.conf:

WSGIScriptAlias /trac d:/web/trac/apache/trac.wsgi

<Directory d:/web/trac/apache>
    WSGIApplicationGroup %{GLOBAL}
    Order deny,allow
    Allow from all

A chunk of nginx.conf

server {
    location /trac {

Where to dig?

Threat in the track to climb there is absolutely no desire.

ZZY Why such a perversion? Well, that's how the chip lay down, ligaments-ligaments-ligaments …


I solved it in nginx.

server {
    location = /trac/ {
        proxy_hide_header Content-Type;
        add_header Content-Type text/xml;
    location /trac/ {

Threat I suffered for half a day.

Scroll to Top