Nextcloud AIO interface behind Nginx in a subfolder

Hello,

I’m trying to run the AIO interface behind Nginx (because I want a valid domain name, a valid certficate and also add some HTTP auth) but in a subfolder/subdirectory.

It works on https://domain.example.com but I want it on https://domain.example.com/subfolder, is it possible?

Here the working Nginx config for hosting it at the root domain:

map $http_upgrade $connection_upgrade {
    default upgrade;
    '' close;
}

server {
    server_name domain.example.com;
    listen 443 ssl http2;
    index index.html index.htm;

[...]

    location /aio/ {
        proxy_pass https://127.0.0.1:8080$request_uri;

        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Port $server_port;
        proxy_set_header X-Forwarded-Scheme $scheme;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $host;

        proxy_request_buffering off;
        proxy_read_timeout 86400s;
        client_max_body_size 0;

        # Websocket
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
    }
}

how can I adapt it to work for a subfolder/subdirectory? (changing location / returns a 404 error.

Hm, I never tried but I think the AIO interface does not support subfolders. You should be able to use a different port for it though, for example…

Yes, I can use another port.

Though I would prefer to host all (AIO interfaces but also other software like monitoring) my ‘admin’ interfaces below a unique domain name and port.
I may ask more information in a github issue.

I have not tested AIO with this configuration, but I wrote up a solution for the micro-services image. You can see it here for subfolder deployments.

The key (but not the only requirement), in Nginx, is including a slash at the end of the proxy_pass directive so that Nginx knows to strip the prefix from the URI.

@jtr I have tested the solution you provide, but it does not seems to work with AIO admin interface.

Adding the ‘slash’ (and removing $request_uri) looks like it does the job, I see in the nextcloud-aio-mastercontainer the following line in Apache log

<REDACTED_IP> - - [22/Oct/2024:12:34:20 +0000] "GET / HTTP/1.1" 302 - "-" "<REDACTED_UA>"

but I got a redirect to https://domain.example.com/login which you be /nextcloud/login
It seems that the OVERWRITEWEBROOT directive is not supported.

The directives will need to be adapted to AIO (or their equivalents manually placed in your config.php), at a minimum, I’d expect.

I do see support for OVERWRITEWEBROOT being passed as an environment variable in AIO here. Does overwritewebroot appear in the output of occ config:list system?

I do see support for OVERWRITEWEBROOT being passed as an environment variable in AIO here . Does overwritewebroot appear in the output of occ config:list system?

The AIO admin interface runs in the mastercontainer (all-in-one/Containers/mastercontainer at 026b1b87fa71d7c0f485b25c7bd0c4fcb24c6026 · nextcloud/all-in-one · GitHub) which is not the same as the nextcloud one.

I will dig into it and see if I can find which directive to use, or a way to adapt the container

edit: but I fear that I will need to dig into the code and I don’t know PHP so not sure I’ll be able to

Oh, right. You’re specifically looking to do it for the AIO admin interface, not Nextcloud Server itself.

Discussion continues on Github Any possibility to host the AIO admin interface behind a reverse proxy (Nginx) but in a subfolder/subdirectory? · nextcloud/all-in-one · Discussion #5480 · GitHub