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.
我将进入django项目的生产模式,但遇到了一个特殊的问题。我正在通过apahce+mod_wsgi运行django,并通过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?
然而,我的情况要求我不能提供nginx的“所有”静态文件。有必要只提供“打开-flash-图表”。从apache主权财富基金”。该项目使用openpyc并嵌入打开的flash图表。swf需要与django在同一台服务器上运行,在我的例子中是Apache。我怎样才能做到呢?我需要对Apache配置文件做哪些更改?
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;
}
}
2
In Apache, set up an alias in your virtual host to serve this file directly:
在Apache中,在您的虚拟主机中设置一个别名来直接服务这个文件:
Alias /url/to/open-flash-chart.swf /full/path/to/open-flash-chart.swf
Then, instead of using {{ MEDIA_URL }}
to reference the file, code in the absolute path:
然后,不是使用{MEDIA_URL}来引用文件,而是使用绝对路径中的代码:
<object data="/url/to/open-flash-chart.swf" />
Nginx will still proxy the request (because it's not your media path), and then Apache will deliver the file back to nginx.
Nginx仍然代理请求(因为它不是您的媒体路径),然后Apache将把文件返回给Nginx。
Alternatively, and not recommended, but if it must go straight from Apache to the browser, you could specify the port:
或者,也不推荐,但是如果它必须直接从Apache到浏览器,您可以指定端口:
<object data="http://servername:8080/url/to/open-flash-chart.swf" />
-1
You need to change nginx config to handle
您需要更改要处理的nginx配置
/path/to/open-flash-chart.swf
with apache, same way you did it for / (root)
使用apache时,也可以使用/ (root)
本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.silva-art.net/blog/2011/01/27/ee4a9aff943f7fc300b7f8ef03e6e106.html。