Setting up nginx as proxy to apache; All good, but nginx doesn't serve media

Posted by becomingGuru on Server Fault See other posts from Server Fault or by becomingGuru
Published on 2010-04-05T12:34:49Z Indexed on 2010/04/05 12:43 UTC
Read the original article Hit count: 369

Filed under:
|
|
|

I have set it up such that nginx proxies request and sends django requests to apache and serves media itself.

Following documents my setup:

Nginx Configuration: /etc/nginx/nginx.conf

user www-data;
worker_processes  1;

error_log  /var/log/nginx/error.log;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
}

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;

    include /etc/nginx/sites-enabled/*;

}

=====

ngnix proxy /etc/nginx/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 server file: /etc/nginx/sites-enabled/some-name.txt

==========
server {

    listen 208.109.252.110:80;
    server_name netconf;

    autoindex on;


    access_log /home/site/server_logs/nginx_access.log;
    error_log /home/site/server_logs/nginx_error.log;

    location / {
    proxy_pass http://127.0.0.1:80/;
    include /etc/nginx/proxy.conf;
    }

    location /site_media/ {
        root /home/site/folder/static;
    }

 }

==========

Nginx very well proxies the request and passes to apache, the required requests, but doesn't serve the media. In the last server file, location site_media is not served, at all. :(

Everything seems perfect to me. What is wrong?

Thanks in advance.

© Server Fault or respective owner

Related posts about nginx

Related posts about apache