簡體   English   中英

NGINX:CSS 未加載,因為它的 MIME 類型“text/plain”不是“text/css”

[英]NGINX: CSS was not loaded because its MIME type, "text/plain", is not "text/css"

通過不同的文章搜索和瀏覽了很多之后,我仍然沒有解決以下問題:

我收到 Firefox 錯誤消息:

The stylesheet https://www.xxxxxx.at/assets/css/main.css was not loaded because its MIME type, "text/plain", is not "text/css".

我在 Docker 中運行 nginx:stable 並使用以下 /etc/nginx/nginx.conf:

 events {
    worker_connections 1024;
}
http {
    server_names_hash_bucket_size 64;
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    server {
        listen 80 default_server;
        listen [::]:80 default_server;

        location / {
            return 301 https://$host$request_uri;
        }
    }

    server {
        listen 443 ssl http2;
        listen [::]:443 ssl http2;

        server_name XXXXXXXX;

        root /site_data/XXXXXXXX;
        index index.html index.htm;

        location / { }

        ssl_certificate /ssl/XXXXXXXX.pem;
        ssl_certificate_key /ssl/XXXXXXXX.pem;
        ssl_session_timeout 1d;
        ssl_session_cache shared:MozSSL:10m;  # about 40000 sessions
        ssl_session_tickets off;

        # modern configuration
        ssl_protocols TLSv1.3;
        ssl_prefer_server_ciphers off;

    }
}

我的網站基本上是:

<html>
    <head>
    ...
    <link rel="stylesheet" type="text/css" href="assets/css/main.css" />
    ...
    </head>
    <body>...</body>
</html>

有誰知道這個 Firefox/Chrome 問題的解決方案? 謝謝!

這已解決,似乎是一個緩存問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM