我使用的是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