我使用的是Apache + mod_wsgi for django。
并且所有css/js/images
通过nginx
服务。
对于一些奇怪的原因,当others/friends/colleagues
尝试访问该网站,jquery/css
是not getting loaded
他们,因此该页面看起来混乱起来。django:通过nginx提供静态文件
我的HTML文件中使用这样的代码 -
<link rel="stylesheet" type="text/css" href="http://x.x.x.x:8000/css/custom.css"/>
<script type="text/javascript" src="http://1x.x.x.x:8000/js/custom.js"></script>
在sites-available
我的nginx的配置是这样的 -
server {
listen 8000;
server_name localhost;
access_log /var/log/nginx/aa8000.access.log;
error_log /var/log/nginx/aa8000.error.log;
location/{
index index.html index.htm;
}
location /static/ {
autoindex on;
root /opt/aa/webroot/;
}
}
有已相应css
& js
目录的目录/opt/aa/webroot/static/
。
奇怪的是,当我访问它们时页面显示正常。
我已经清除了我的缓存/ etc,但从各种浏览器加载的页面都很好。
此外,我没有看到404在nginx日志文件中的任何错误。
任何指针都会很棒。
除非你在你的nginx配置文件中还有“位置/静态”等Django将服务于静态文件。很好的测试和开发,但不是一个好主意的生产。 – ostergaard 2013-04-10 11:05:13