使用 Nginx 添加 SSL 证书后,Hugo 站点 CSS 未加载

Hugo site CSS not loading after adding SSL certificate with Nginx

https://www.greenhousemarketplace.com

全新安装 certbot 并强制 HTTPS 重定向后,我的 CSS 和 JS 不再加载,即使可以通过直接 URL.

访问

我不确定为什么,我已经更新了指向 CSS 和 JS 文件的链接,并将我的 config.toml 设置为包含 https 前缀。

sites-enabled/ghm-landing-page

server {
        root /var/www/ghm-landing-page/public/;

        index index.html index.htm index.nginx-debian.html;

        server_name greenhousemarketplace.com;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
        }

    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/greenhousemarketplace.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/greenhousemarketplace.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}


server {
    if ($host = greenhousemarketplace.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


        listen 80 default_server;
        listen [::]:80 default_server;

        server_name greenhousemarketplace.com;
    return 404; # managed by Certbot

config.toml

# Site settings
baseurl = "https://www.greenhousemarketplace.com/"
languageCode = "en-us"
title = "Greenhouse Marketplace"
theme = "hugo-highlights-theme"

Javascript 未加载,因为您正在加载混合内容。 页面底部的脚本标签应使用 https:// 方案。

由于 SSL_ERROR_BAD_CERT_DOMAIN 错误,CSS 未加载。您在 www. 上加载了内容,该域未在您的证书中列出。 使用您的证书颁发者,确保同时添加 www.和非 www。您的域的域。