首先,我想说明,我已阅读并尝试了所有关于此主题的SO问题的解决方案。
没有什么帮助,但我的问题也比平时有很大的不同。Nginx只为django应用程序部分提供静态文件
我有我的开发计算机上安装的django项目(runserver和gunicorn),这意味着staticfiles服务。
值得一提的是,我最近因硬件问题将我的开发环境迁移到了新系统(这里的外包装是我最近安装的这个项目)。
当我尝试其他系统上安装它(新安装ubuntu 13.10的针对我的安装脚本已被写入)我遇到这个奇怪的问题,不是所有的静态文件都是由nginx的服务。
'并非所有'都意味着一些css文件被提供,有些不是;同样适用于js。
是的,他们所有的文件都在相同的静态目录,是的他们都在那里。 此外,它可能不是配置问题,因为在这两种情况下(我的开发机器的一切运行良好,这个测试一个没有)有完全相同的配置。 文件的privilages都是一样的。 nginx的日志中没有任何东西。
它必须是非常愚蠢但异国情调的东西,或者我不知道......伏都教? 我的意思是,如果nginx不会提供任何服务,那么我会管理 - 这显然会出现一些错误 - 但是,如果一个文件是由另一个来自完全相同的地方而不是? 也有可能相同的设置为一个系统上的所有文件提供服务,而另一个系统上只有很少的文件?
我没有在这里包括任何配置等,因为,正如我上面所述,我不认为他们是问题在这里;然而,如果有人觉得需要确保自己急于发布,只需说一句话。
在此先感谢你们,我求求你的帮助,即时绝望和不以为耻。
它已经已经三天期限是不会去任何地方......
我/etc/nginx/nginx.conf(基本上默认的):从网站
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/x-javascript text/xmlapplication/xml applicatio
##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##
#include /etc/nginx/naxsi_core.rules;
##
# nginx-passenger config
##
# Uncomment it if you installed nginx-passenger
##
#passenger_root /usr;
#passenger_ruby /usr/bin/ruby;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}
站点配置 - 启用:
server {
listen 80;
server_name webapp.org;
access_log /var/log/nginx_access.log;
error_log /var/log/nginx_error.log;
location /static {
root /home/myuser/app;
}
location /sse {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_buffering off;
proxy_next_upstream error;
proxy_read_timeout 600;
proxy_pass http://127.0.0.1:8888;
}
location /pacs {
proxy_pass http://127.0.0.1:8080/;
}
location/{
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://127.0.0.1:8888;
}
}
两个问题。 1)“没有服务”是什么意思?请求该文件时,nginx返回什么? 2)你的意思是“nginx日志中没有任何内容”?一点都没有? – dukebody 2014-12-02 11:36:13
是的,发布你的nginx配置和日志(如果有的话)一定会帮助人们找出可能发生的事情。 – dukebody 2014-12-02 11:37:04
1)它返回404 2)什么都没有...... – 4rlekin 2014-12-02 11:37:14