# SSI working on Apache backend, but not on gunicorn backend

**URL:** <https://www.ruby-forum.com/t/ssi-working-on-apache-backend-but-not-on-gunicorn-backend/237245>\
**Category:** NGINX\
**Created:** [October 31, 2013, 3:34pm UTC](https://www.ruby-forum.com/t/ssi-working-on-apache-backend-but-not-on-gunicorn-backend/237245 "2013-10-31T15:34:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Detlef\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58f4c7/32.png) [@Detlef\_R](https://www.ruby-forum.com/u/Detlef_R)\
**Post date:** [October 31, 2013, 3:34pm UTC](https://www.ruby-forum.com/t/ssi-working-on-apache-backend-but-not-on-gunicorn-backend/237245/1 "2013-10-31T15:34:02Z")

</div>

Hello,

I have nginx in front of an Apache server and a gunicorn server for  
different parts of my website. I am using the SSI module in nginx to  
display  
a snippet in every page. The websites include a snippet in this form:

For static pages served by nginx everything is working fine, the same  
goes  
for the Apache-generated pages - the SSI include is evaluated and the  
snippet is filled. However for requests to my gunicorn backend running a  
Python app in Django, the SSI include does not get evaluated.

Here is the relevant part of the nginx config:

```
location /cgi-bin/script.pl {
     ssi on;
     proxy_pass http://default_backend/cgi-bin/script.pl;
     include sites-available/aspects/proxy-default.conf;
}

location /directory/ {
     ssi on;
     limit_req zone=directory nodelay burst=3;
     proxy_pass http://django_backend/directory/;
     include sites-available/aspects/proxy-default.conf;
}

```

Backends:  
upstream django\_backend {  
server [dynamic.mydomain.com:8000](http://dynamic.mydomain.com:8000) max\_fails=5 fail\_timeout=10s;  
}  
upstream default\_backend {  
server [dynamic.mydomain.com:80](http://dynamic.mydomain.com:80);  
server [dynamic2.mydomain.com:80](http://dynamic2.mydomain.com:80);  
}

proxy\_default.conf:

proxy\_redirect off;  
proxy\_set\_header Host $host;  
proxy\_set\_header X-Real-IP $remote\_addr;  
proxy\_set\_header X-Forwarded-For $proxy\_add\_x\_forwarded\_for;

What is the cause for this behaviour? How can I get SSI includes working  
for  
my pages generated on gunicorn? How can I debug this further?

Thank you for your help!

Best regards,

Jonas

Posted at Nginx Forum:

> **[SSI working on Apache backend, but not on gunicorn backend](https://forum.nginx.org/read.php?2,244299,244299#msg-244299)**
>
> Hello, I have nginx in front of an Apache server and a gunicorn server for different parts of my website. I am using the SSI module in nginx to display a snippet in every page. The websites include a snippet in this form: \<!--# include...

---

<div class="post-metadata">

**Author:** ![j0nes2k](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/6bbea6/32.png) [@j0nes2k](https://www.ruby-forum.com/u/j0nes2k)\
**Post date:** [October 31, 2013, 5:35pm UTC](https://www.ruby-forum.com/t/ssi-working-on-apache-backend-but-not-on-gunicorn-backend/237245/2 "2013-10-31T17:35:00Z")

</div>

Hello!

On Thu, Oct 31, 2013 at 10:33:33AM -0400, j0nes2k wrote:

> Python app in Django, the SSI include does not get evaluated.  
> […]

> What is the cause for this behaviour? How can I get SSI includes working for  
> my pages generated on gunicorn? How can I debug this further?

Possible reasons, in no particular order:

- Content-Type of responses returned by gunicorn isn’t listed in  
ssi\_types in your nginx config.

- Responses returned by gunicorn are compressed (use  
“Content-Encoding: gzip” or alike).

Further debugging can be done e.g. using a debug log, see  
[A debugging log](http://nginx.org/en/docs/debugging_log.html).

–  
Maxim D.  
[http://nginx.org/en/donation.html](http://nginx.org/en/donation.html)

---

<div class="post-metadata">

**Author:** ![j0nes2k](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/6bbea6/32.png) [@j0nes2k](https://www.ruby-forum.com/u/j0nes2k)\
**Post date:** [November 1, 2013, 8:45am UTC](https://www.ruby-forum.com/t/ssi-working-on-apache-backend-but-not-on-gunicorn-backend/237245/3 "2013-11-01T08:45:50Z")

</div>

Hello Maxim,

thank you for your help! The hint that lead me to the solution was about  
Gzipped output from gunicorn. In the Django settings.py I activated the  
GZip  
Middleware. After removing this, the SSI includes work correctly.

Best regards,

Jonas

Posted at Nginx Forum:

> **[Re: SSI working on Apache backend, but not on gunicorn backend](https://forum.nginx.org/read.php?2,244299,244316#msg-244316)**
>
> Hello, I have nginx in front of an Apache server and a gunicorn server for different parts of my website. I am using the SSI module in nginx to display a snippet in every page. The websites include a snippet in this form: \<!--# include...
