2017-08-16 381 views
0

我试图在子目录中运行Rainloop。 http://babylon/webmail。我得到的CSS和JS无法识别。例如:css和图像无法被nginx识别:资源被解释为样式表,但使用MIME类型text/html传输

Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://babylon/webmail/rainloop/v/1.10.5.192/static/css/rainloop/v/1.10.5.192/static/css/app.min.css?standard". 

一些可能(但没有工作)解决方案,我想:

  1. “包括/etc/nginx/mime.types;”在nginx.conf中找到。
  2. 有人说,PHP的位置被搞砸了那一部分,所以我应该加入这一行:

    fastcgi_split_path_info ^(。+ PHP)(/.+)$; #这行

但仍然无效。

  1. 我使用root为css和javascript添加新位置,但也没有任何提示。

我的配置是这样的一种:(它是一个包含文件)

location ^~ /webmail { 
    root /srv/rainloop/public_html; 
    try_files $uri $uri/ /webmail/index.php?$query_string; 
    access_log /srv/rainloop/logs/access.log; 
    error_log /srv/rainloop/logs/error.log; 
    index index.php; 
    access_log /var/log/nginx/scripts.log scripts; 

    location ~ \.php$ { 
     #if (!-f $request_filename) { return 404; } 
     include fastcgi_params; 
     #fastcgi_split_path_info ^(.+\.php)(/.+)$; #this line 
     fastcgi_pass unix:/var/run/php5-fpm.sock; 
     fastcgi_index index.php; 
     #fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
     fastcgi_param SCRIPT_FILENAME /srv/rainloop/public_html/index.php; 
    } 

    location ~ /\.ht { 
     deny all; 
    } 

    location ^~ /webmail/data { 
     deny all; 
    } 
} 

回答

1

我认为它可以解决你的问题。

location ~ \.css { 
    add_header Content-Type text/css; 
} 
location ~ \.js { 
    add_header Content-Type application/x-javascript; 
} 
+0

@Sanan_Guliyev我现在得到一个404的js和css文件。 “open()”/var/www/html/rainloop/v/1.10.5.192/static/js/min/boot.min.js“failed”应该是:“/ srv/rainloop/public_html/rainloop/v/1.10.5.192/static/js/min/boot.min.js”。我在所有这两个位置都添加了root,但仍不能修复路径。 – Ruben

+0

为我工作! –

相关问题