nginx 反向代理後面的 apache 上的 Nextcloud 在 index.php 重定向上回傳 404

nginx 反向代理後面的 apache 上的 Nextcloud 在 index.php 重定向上回傳 404

我在 apache (+php-fpm) 上作為 docker 容器和我的 nginx 反向代理運行的 nextcloud 實例遇到問題。

當我打開 Nextcloud URL 時,nginx 會將請求代理到 apache,然後 apache 將我重新導向到 /index.php/login。但是,由於某種原因,nginx 對 /index.php/login 傳回 404。

這是我的 nginx 日誌:

172.19.0.0 - - [29/Nov/2021:22:32:01 +0000] "GET / HTTP/1.1" 302 0 "-" "Some UA-String"

172.19.0.0 - - [29/Nov/2021:22:32:01 +0000] "GET /index.php/login HTTP/1.1" 404 548 "-" "Some UA-String"

我的 nginx 設定:

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

    server_name cloud.example.com;

    ssl_certificate     [...];
    ssl_certificate_key [...];

    location / {
        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 $scheme;
        proxy_buffering off;
        proxy_request_buffering off;
        proxy_http_version 1.1;
        proxy_intercept_errors on;

        proxy_pass http://nextcloud-httpd; #nextcloud-httpd is apaches hostname in the docker network
    }

}

為什麼 nginx 不將 /index.php/login 傳遞給 apache 但傳遞所有其他請求?哦,如果我直接訪問 apache 一切正常,所以它必須是 nginx 代理。

感謝您的幫助〜anghenfil

答案1

我發現問題了!我需要將 overwriteprotocol 選項新增至我的 nextcloud 配置以堅持使用 https。基本上每次我被重新導向時,nextcloud 都會將我重新導向到 http,這是反向代理和典型 RTFM 情況的已知問題:https://docs.nextcloud.com/server/19/admin_manual/configuration_server/reverse_proxy_configuration.html

最好的安格菲爾

相關內容