Senaite LIMS (Plone 4.3.18) css 无法在启用 https 的 Nginx 上运行

Senaite LIMS (Plone 4.3.18) css not working on Nginx with https enabled

我已经在统一安装程序安装的 Plone 4.3.18 上安装并设置了 senaite.lims,这是一个 Plone 扩展 运行,并将 senaite.lims 添加到 buildout.cfg鸡蛋。

在端口 8080 上 运行 没问题,我可以让 Nginx 将 / 重定向到 :8080,但是当我开始使用 https 时,网站的 css 突然不起作用没有了。

我查看了源代码,生成的 html 页面显示 link 到带有 http://.... 的样式表,我不知道这是否会导致问题,但如果我真的尝试在浏览器中打开 .css 文件,它工作正常。

我设置并尝试使用端口 80 重定向 https,并同时提供一个版本的 http 和 https,但都无法使用 .css 呈现页面。如果有人有任何提示,或在下面的 nginx 中看到配置错误的地方,将不胜感激。

这是我的 nginx.conf:

user www-data;
worker_processes auto;
pid /run/nginx.pid;

events {
    worker_connections 768;
}

http {
    default_type  application/octet-stream;
    include /etc/nginx/mime.types;
    sendfile    on;
    keepalive_timeout 75;

    upstream plone {
        server 127.0.0.1:8080;
    }

    server {
        listen              80;
        listen              443 ssl http2;
        server_name         99.99.99.99; # changed for posting on SO
        ssl_certificate     /etc/ssl/certs/nginx-selfsigned.crt;
        ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;

        error_log /var/log/nginx/nginx.vhost.error.log;

        location / {
        proxy_pass                http://localhost:8080/;
        proxy_redirect            off;
        proxy_set_header          Host               $host;
        proxy_set_header          X-Real-IP          $remote_addr;
        proxy_set_header          X-Forwarded-For    $proxy_add_x_forwarded_for;
        proxy_set_header          X-Forwarded-Proto  https;
        proxy_buffer_size         128k;
        proxy_buffers             8 128k;
        proxy_busy_buffers_size   256k;
        }
    }
}

您错过了重写 URL,例如:

rewrite ^(.*)$ /VirtualHostBase/$scheme/$host/senaite/VirtualHostRoot/ break;

这是 SENAITE 的完整工作配置:

server {
    listen 80;
    server_name senaite.mydomain.com;
    return 301 https://$server_name$request_uri;
}

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

    server_name senaite.mydomain.com;

    # https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-16-04
    include snippets/ssl-senaite.mydomain.com.conf;
    include snippets/ssl-params.conf;
    include snippets/well-known.conf;

    access_log /var/log/nginx/senaite.access.log;
    error_log /var/log/nginx/senaite.error.log error;

    # Allow Cross-Origin Resource Sharing from our HTTP domain
    add_header "Access-Control-Allow-Origin" "http://senaite.ridingbytes.com";
    add_header "Access-Control-Allow-Credentials" "true";
    add_header "Access-Control-Allow-Methods" "GET, POST, OPTIONS";
    add_header "X-Frame-Options" "SAMEORIGIN";

    if ($http_cookie ~* "__ac=([^;]+)(?:;|$)" ) {
        # prevent infinite recursions between http and https
        break;
    }
    # rewrite ^(.*)(/logged_out)(.*) http://$server_name redirect;

    location / {
        set $backend http://haproxy;
        # API calls take a different backend w/o caching
        if ($uri ~* "@@API") {
            set $backend http://api;
        }
        proxy_set_header        Host            $http_host;
        proxy_set_header        X-Real-IP       $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        rewrite                 ^(.*)$ /VirtualHostBase/$scheme/$host/senaite/VirtualHostRoot/ break;
        # proxy_pass              $backend;
        proxy_pass              http://plone;
    }
}