2

I'm going into production mode for my django project, but running into a peculiar problem. I'm running my django through apahce+mod_wsgi and serving static files through nginx.

However my situation demands that I cannot serve "all" static files from nginx. There is a need to serve only "open-flash-chart.swf" from apache. The project uses openpyc and embeds open-flash-chart.swf which needs to run on same server as django, which in my case is Apache. How can I accomplish that? What changes to I need to make into Apache config files?

server {
listen   80 default;
server_name  localhost;

access_log  /var/log/nginx/localhost.access.log;

location / {
    proxy_pass http://localhost:8080;
    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; 
}
location /media/ {
    root /srv/www/enpass/;
    expires max;
}
}
4

2 に答える 2

2

Apache で、仮想ホストにエイリアスを設定して、このファイルを直接提供します。

Alias /url/to/open-flash-chart.swf /full/path/to/open-flash-chart.swf

次に、 を使用してファイルを参照する代わりに{{ MEDIA_URL }}、絶対パスでコードを記述します。

<object data="/url/to/open-flash-chart.swf" />

Nginx は引き続きリクエストをプロキシし (メディア パスではないため)、Apache はファイルを nginx に送り返します。

または、お勧めしませんが、Apache からブラウザーに直接接続する必要がある場合は、ポートを指定できます。

<object data="http://servername:8080/url/to/open-flash-chart.swf" />
于 2011-01-27T22:53:17.200 に答える
-1

処理するようにnginx構成を変更する必要があります

/path/to/open-flash-chart.swf 

/(ルート)に対して行ったのと同じ方法で、Apacheを使用します

于 2011-01-27T21:59:03.900 に答える