SSI working on Apache backend, but not on gunicorn backend

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 max_fails=5 fail_timeout=10s;
}
upstream default_backend {
server dynamic.mydomain.com:80;
server 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:
http://forum.nginx.org/read.php?2,244299,244299#msg-244299

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
http://nginx.org/en/docs/debugging_log.html.


Maxim D.
http://nginx.org/en/donation.html

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:
http://forum.nginx.org/read.php?2,244299,244316#msg-244316

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs