Score:0

NGINX+wordpress: CSS being served but not applied

ru flag
sxx

Cheers fellow stackers,

I kinda have to get wordpress running in a self hosted nginx environment.

More or less exactly using the suggested config from NGINX wordpress doc.

server {
    listen 443 ssl;
    server_name _;
    ssl_certificate /var/lib/nginx/PKI/www/server/cert.pem;
    ssl_certificate_key /var/lib/nginx/PKI/www/server/key.pem;
    root /var/lib/nginx/www/wordpress;
    index index.php;
    location / {
            try_files $uri uri/ /index.php?$args;

    }
    location ~ \.php$ {
        include /etc/nginx/fastcgi_params;
        fastcgi_intercept_errors on;
        fastcgi_pass php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
            expires max;
    }
}

Everything works mostly as expected, except for the styling. No styling seems to be applied on the site (also applies to the admin login/quickstart wizard).

Inside of the admin dashboard, everything looks fine.

CSS files are being served properly by NGINX.

Tim avatar
gp flag
Tim
If you post a link to your site we can have a look directly, which would be easier
Score:0
ru flag
sxx

My nginx config did not include the mime.types defaults.

That seems to be affecting the nginx "Content-Type" response header, leading to it being "text/plain" instead of "text/css" ...

... which is unfortunate because none of the wordpress templates specify the content type in the request, e.g:

<link rel='stylesheet' id='wp-block-library-css'  href='https://censored.net/wp-includes/css/dist/block-library/style.css?ver=5.8' media='all' />

Should probably look anything like this, but oh well

<link rel="styleseeht" type="text/css" ...>
djdomi avatar
za flag
Please Improve your Answer, tell us what you have changed because it would help to answer this question, even IMHO this would only fit on Superuser
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.