Skip to main content
4 of 5
deleted 327 characters in body
sxx
  • 11
  • 2

NGINX+wordpress: CSS being served but not applied

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.

Admin login screenshot

(changed background color for visibility)

Also broken on the actual site:

enter image description here

(changed background color for visibility)

Inside of the admin dashboard, everything looks fine.

As far as I can tell, the corresponding CSS files are being served properly by nginx: enter image description here

I've tried everything mentioned here.

Does anybody happen to know whats wrong? I'm running out of ideas.

If I click on the CSS links in the browser source, they're available as I'd expect them to be. enter image description here

nginx debug log looks good:

2021/09/01 01:15:10 [debug] 12620#12620: *3 http request line: "GET /wp-content/themes/twentytwentyone/style.css?ver=1.4 HTTP/1.1"
2021/09/01 01:15:10 [debug] 12620#12620: *3 http uri: "/wp-content/themes/twentytwentyone/style.css"
2021/09/01 01:15:10 [debug] 12620#12620: *3 http args: "ver=1.4"
2021/09/01 01:15:10 [debug] 12620#12620: *3 http exten: "css"
2021/09/01 01:15:10 [debug] 12620#12620: *3 posix_memalign: 00005575C1B91D30:4096 @16
2021/09/01 01:15:10 [debug] 12620#12620: *3 http process request header line
2021/09/01 01:15:10 [debug] 12620#12620: *3 http header: "Host: censored.net"
2021/09/01 01:15:10 [debug] 12620#12620: *3 http header: "Connection: keep-alive"
2021/09/01 01:15:10 [debug] 12620#12620: *3 http header: "sec-ch-ua: "Chromium";v="92", " Not A;Brand";v="99", "Google Chrome";v="92""
2021/09/01 01:15:10 [debug] 12620#12620: *3 http header: "sec-ch-ua-mobile: ?0"
2021/09/01 01:15:10 [debug] 12620#12620: *3 http header: "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36"
2021/09/01 01:15:10 [debug] 12620#12620: *3 http header: "Accept: text/css,*/*;q=0.1"
2021/09/01 01:15:10 [debug] 12620#12620: *3 http header: "Sec-Fetch-Site: same-origin"
2021/09/01 01:15:10 [debug] 12620#12620: *3 http header: "Sec-Fetch-Mode: no-cors"
2021/09/01 01:15:10 [debug] 12620#12620: *3 http header: "Sec-Fetch-Dest: style"
2021/09/01 01:15:10 [debug] 12620#12620: *3 http header: "Referer: https://censored.net/"
2021/09/01 01:15:10 [debug] 12620#12620: *3 http header: "Accept-Encoding: gzip, deflate, br"
2021/09/01 01:15:10 [debug] 12620#12620: *3 http header: "Accept-Language: en-US,en;q=0.9,de;q=0.8,ko;q=0.7,zh-TW;q=0.6,zh;q=0.5,ja;q=0.4,ru;q=0.3"
2021/09/01 01:15:10 [debug] 12620#12620: *3 http header done
2021/09/01 01:15:10 [debug] 12620#12620: *3 generic phase: 0
2021/09/01 01:15:10 [debug] 12620#12620: *3 rewrite phase: 1
2021/09/01 01:15:10 [debug] 12620#12620: *3 test location: "/"
2021/09/01 01:15:10 [debug] 12620#12620: *3 test location: ~ "\.php$"
2021/09/01 01:15:10 [debug] 12620#12620: *3 test location: ~ "\.(js|css|png|jpg|jpeg|gif|ico)$"
2021/09/01 01:15:10 [debug] 12620#12620: *3 using configuration "\.(js|css|png|jpg|jpeg|gif|ico)$"
2021/09/01 01:15:10 [debug] 12620#12620: *3 http cl:-1 max:52428800
2021/09/01 01:15:10 [debug] 12620#12620: *3 rewrite phase: 3
2021/09/01 01:15:10 [debug] 12620#12620: *3 post rewrite phase: 4
2021/09/01 01:15:10 [debug] 12620#12620: *3 generic phase: 5
2021/09/01 01:15:10 [debug] 12620#12620: *3 generic phase: 6
2021/09/01 01:15:10 [debug] 12620#12620: *3 generic phase: 7
2021/09/01 01:15:10 [debug] 12620#12620: *3 access phase: 8
2021/09/01 01:15:10 [debug] 12620#12620: *3 access phase: 9
2021/09/01 01:15:10 [debug] 12620#12620: *3 access phase: 10
2021/09/01 01:15:10 [debug] 12620#12620: *3 post access phase: 11
2021/09/01 01:15:10 [debug] 12620#12620: *3 try files phase: 12
2021/09/01 01:15:10 [debug] 12620#12620: *3 content phase: 13
2021/09/01 01:15:10 [debug] 12620#12620: *3 content phase: 14
2021/09/01 01:15:10 [debug] 12620#12620: *3 content phase: 15
2021/09/01 01:15:10 [debug] 12620#12620: *3 content phase: 16
2021/09/01 01:15:10 [debug] 12620#12620: *3 content phase: 17
2021/09/01 01:15:10 [debug] 12620#12620: *3 http filename: "/var/lib/nginx/www/wordpress/wp-content/themes/twentytwentyone/style.css"
sxx
  • 11
  • 2