未解析样式表,因为严格模式下不允许非CSS MIME类型

时间:2016-06-04 10:40:23

标签: css nginx mime

我的网站上收到以下错误:

[Error] Did not parse stylesheet at 'http://test.opendialogueapproach.co.uk/wp-content/plugins/revslider/public/assets/css/settings.css?ver=5.2.5.3' because non CSS MIME types are not allowed in strict mode.

做了一些研究后,似乎这可能与我的nginx配置有关,但我的nginx文件似乎与我在其他地方看到的结构有很大不同,所以我不确定需要哪些修改才能解决问题。我包括下面看起来相关的三个nginx文件:

首先是etc / nginx中的mime.conf文件 然后是nginx.conf,也在etc / nginx中 最后是我的网站的conf文件在etc / nginx / conf.d

mime.conf

types {
    text/html                             html htm shtml;
    text/css                              css;
    text/xml                              xml rss;
    image/gif                             gif;
    image/jpeg                            jpeg jpg;
    application/x-javascript              js;
    text/plain                            txt;
    text/x-component                      htc;
    text/mathml                           mml;
    image/png                             png;
    image/svg+xml                         svg svgz;
    image/x-icon                          ico;
    image/x-jng                           jng;
    image/vnd.wap.wbmp                    wbmp;
    application/java-archive              jar war ear;
    application/mac-binhex40              hqx;
    application/pdf                       pdf;
    application/x-cocoa                   cco;
    application/x-java-archive-diff       jardiff;
    application/x-java-jnlp-file          jnlp;
    application/x-makeself                run;
    application/x-perl                    pl pm;
    application/x-pilot                   prc pdb;
    application/x-rar-compressed          rar;
    application/x-redhat-package-manager  rpm;
    application/x-sea                     sea;
    application/x-shockwave-flash         swf;
    application/x-stuffit                 sit;
    application/x-tcl                     tcl tk;
    application/x-x509-ca-cert            der pem crt;
    application/x-xpinstall               xpi;
    application/zip                       zip;
    application/octet-stream              deb;
    application/octet-stream              bin exe dll;
    application/octet-stream              dmg;
    application/octet-stream              eot;
    application/octet-stream              iso img;
    application/octet-stream              msi msp msm;
    audio/mpeg                            mp3;
    audio/ogg                             oga ogg;
    audio/wav                             wav;
    audio/x-realaudio                     ra;
    video/mp4                             mp4;
    video/mpeg                            mpeg mpg;
    video/ogg                             ogv;
    video/quicktime                       mov;
    video/webm                            webm;
    video/x-flv                           flv;
    video/x-msvideo                       avi;
    video/x-ms-wmv                        wmv;
    video/x-ms-asf                        asx asf;
    video/x-mng                           mng;
}

nginx.conf

user www-data www-data;
pid /var/run/nginx.pid;
worker_processes 2;
worker_rlimit_nofile 100000;

events {
    worker_connections  4096;
    include /etc/nginx.custom.events.d/*.conf;
}

http {
    default_type application/octet-stream;

    access_log off;
    error_log  /var/log/nginx/error.log crit;

    sendfile on;
    tcp_nopush on;

    keepalive_timeout 20;
    client_header_timeout 20;
    client_body_timeout 20;
    reset_timedout_connection on;
    send_timeout 20;

    types_hash_max_size 2048;

    gzip on;
    gzip_disable "msie6";
    gzip_proxied any;
    gzip_min_length 256;
    gzip_comp_level 4;
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript text/x-js;

    server_names_hash_bucket_size 128;

    include mime.conf;
    charset UTF-8;

    open_file_cache max=100000 inactive=20s;
    open_file_cache_valid 30s;
    open_file_cache_min_uses 2;
    open_file_cache_errors on;

    server_tokens off;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

    include proxy.conf;
    include fcgi.conf;

    include conf.d/*.conf;
    include /etc/nginx.custom.d/*.conf;
}

include /etc/nginx.custom.global.d/*.conf;

网站配置文件:

server {
    listen *:80;


    server_name test.opendialogueapproach.co.uk;

    access_log /var/log/nginx/testopendialogueapproachcouk.access.log;
    error_log /var/log/nginx/testopendialogueapproachcouk.error.log;

    root /var/www/opendialogueapproach.co.uk/test/html;
    index index.html index.htm index.php;

    location / {
        try_files $uri $uri/ /index.php?q=$request_uri;
}

location /wp-content/uploads/bp-attachments/ {
    rewrite ^.*uploads/bp-attachments/([0-9]+)/(.*) /?p=$1&bp-attachment=$2 permanent;
}



    location ~ [^/]\.php(/|$) {



        fastcgi_index index.php;
        include fcgi.conf;
        fastcgi_pass unix:/var/run/ajenti-v-php-fcgi-testopendialogueapproachcouk-php-fcgi-0.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

    }

}

4 个答案:

答案 0 :(得分:0)

我看到消息:“没有指定输入文件。”对于所有链接: http://test.opendialogueapproach.co.uk/wp-content/plugins/revslider/public/assets/css/settings.css http://test.opendialogueapproach.co.uk/wp-content/ http://test.opendialogueapproach.co.uk/wp-content/plugins/revslider/

好像你的网站配置文件不正确。 /var/www/opendialogueapproach.co.uk/test/html/wp-content/plugins/revslider/public/assets/css/settings.css

中可能不存在文件

我认为您应该更正配置中的root,或将文件上传到/var/www/opendialogueapproach.co.uk/test/html

答案 1 :(得分:0)

请注意,如果该页面不存在,并且服务器设置为回退或针对不存在的页面显示一些错误页面,则会出现该错误。

答案 2 :(得分:0)

将身份验证auth_basic放入Nginx时出现此错误。因此,我必须跳过资产文件夹中的身份验证。

location / {
    auth_basic "Restricted Content";
    auth_basic_user_file /etc/nginx/.htpasswd;
}

location ^~ /assets/ {
    auth_basic off;
    gzip_static on;
    expires max;
    add_header Cache-Control public;
}

答案 3 :(得分:-1)

检查您的网址是否有效或页面是否确实存在。您的网址显示“未指定输入”。