Score:0

Nextcloud on apache behind nginx reverse proxy returns 404 on index.php redirects

ph flag

I'm having issues with an nextcloud instance running on apache (+php-fpm) as a docker container and my nginx reverse proxy.

When I open the Nextcloud URL nginx proxies the request to apache and apache redirect me to /index.php/login. However, for some reason, nginx returns an 404 for /index.php/login.

This is my nginx log:

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"

My nginx config:

    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
    }

}

Why does nginx doesn't pass /index.php/login to apache but passes all other requests? Oh and if I'm accessing apache directly everything works, so it have to be the nginx proxy.

Appreciate your help ~anghenfil

Score:1
ph flag

I found the issue! I needed to add the overwriteprotocol option to my nextcloud config to stick to https. Basically every time I got redirected nextcloud redirected me to http, this is an known issue with reverse proxies and a typical RTFM situation: https://docs.nextcloud.com/server/19/admin_manual/configuration_server/reverse_proxy_configuration.html

Best anghenfil

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.