I\'m trying to serve Django static media through nginx, Here\'s my nginx.conf
server {
listen 7777;
listen localhost:7777;
server_name e
the better way would be to use nginx in front of apache and to serve static media:
eg: nginx:
server {
listen 80;
server_name media.example.com;
access_log /var/log/nginx/media.example.com.media.access.log;
location / {
autoindex on;
index index.html;
root /var/www/media.example.com/media;
}
}
server {
listen 80;
server_name www.example.com;
access_log /var/log/nginx/www.example.com.django.access.log;
location / {
proxy_pass http://wwwcluster;
include /etc/nginx/proxy.conf;
}
}
proxy.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;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
nginx.conf:
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
tcp_nodelay on;
gzip on;
upstream wwwcluster {
server 127.0.0.1:8080;
}
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
and configure apache to serve your website on 127.0.0.1:8080
i have this setup on multiple sites and its running perfect. another advantage is, that you can cluster/load-balance your app very easy by adding another apache-server to upstream wwwcluster in nginx.conf