# Nextcloud AIO interface behind Nginx in a subfolder

**URL:** <https://help.nextcloud.com/t/nextcloud-aio-interface-behind-nginx-in-a-subfolder/207327>\
**Category:** ℹ️ Support\
**Tags:** nginx, aio\
**Created:** [October 21, 2024, 2:05pm UTC](https://help.nextcloud.com/t/nextcloud-aio-interface-behind-nginx-in-a-subfolder/207327 "2024-10-21T14:05:52Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![daks](https://help.nextcloud.com/user_avatar/help.nextcloud.com/daks/32/65638_2.png) [@daks](https://help.nextcloud.com/u/daks)\
**Post date:** [October 21, 2024, 2:05pm UTC](https://help.nextcloud.com/t/nextcloud-aio-interface-behind-nginx-in-a-subfolder/207327/1 "2024-10-21T14:05:52Z")

</div>

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](https://domain.example.com)** but I want it on **[https://domain.example.com/subfolder](https://domain.example.com/subfolder)**, is it possible?

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

```auto
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.

---

<div class="post-metadata">

**Author:** ![szaimen](https://help.nextcloud.com/user_avatar/help.nextcloud.com/szaimen/32/63019_2.png) [@szaimen](https://help.nextcloud.com/u/szaimen)\
**Post date:** [October 21, 2024, 2:49pm UTC](https://help.nextcloud.com/t/nextcloud-aio-interface-behind-nginx-in-a-subfolder/207327/2 "2024-10-21T14:49:54Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![daks](https://help.nextcloud.com/user_avatar/help.nextcloud.com/daks/32/65638_2.png) [@daks](https://help.nextcloud.com/u/daks)\
**Post date:** [October 21, 2024, 3:03pm UTC](https://help.nextcloud.com/t/nextcloud-aio-interface-behind-nginx-in-a-subfolder/207327/3 "2024-10-21T15:03:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jtr](https://help.nextcloud.com/letter_avatar/jtr/32/5_5575768a8748004e209b776fc1b2916d.png) [@jtr](https://help.nextcloud.com/u/jtr)\
**Post date:** [October 21, 2024, 6:36pm UTC](https://help.nextcloud.com/t/nextcloud-aio-interface-behind-nginx-in-a-subfolder/207327/4 "2024-10-21T18:36:09Z")

</div>

I have not tested AIO with this configuration, but I wrote up a solution for the micro-services image. You can see it [here](https://github.com/nextcloud/docker/issues/2276#issuecomment-2412389033) 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.

---

<div class="post-metadata">

**Author:** ![daks](https://help.nextcloud.com/user_avatar/help.nextcloud.com/daks/32/65638_2.png) [@daks](https://help.nextcloud.com/u/daks)\
**Post date:** [October 22, 2024, 12:37pm UTC](https://help.nextcloud.com/t/nextcloud-aio-interface-behind-nginx-in-a-subfolder/207327/5 "2024-10-22T12:37:54Z")

</div>

@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

```auto
<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](https://domain.example.com/login) which you be /nextcloud/login  
It seems that the `OVERWRITEWEBROOT` directive is not supported.

---

<div class="post-metadata">

**Author:** ![jtr](https://help.nextcloud.com/letter_avatar/jtr/32/5_5575768a8748004e209b776fc1b2916d.png) [@jtr](https://help.nextcloud.com/u/jtr)\
**Post date:** [October 22, 2024, 12:51pm UTC](https://help.nextcloud.com/t/nextcloud-aio-interface-behind-nginx-in-a-subfolder/207327/6 "2024-10-22T12:51:37Z")

</div>

> [@daks](#):
>
> 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](https://github.com/nextcloud/all-in-one/blob/026b1b87fa71d7c0f485b25c7bd0c4fcb24c6026/Containers/nextcloud/config/reverse-proxy.config.php#L12-L15). Does `overwritewebroot` appear in the output of `occ config:list system`?

---

<div class="post-metadata">

**Author:** ![daks](https://help.nextcloud.com/user_avatar/help.nextcloud.com/daks/32/65638_2.png) [@daks](https://help.nextcloud.com/u/daks)\
**Post date:** [October 22, 2024, 3:23pm UTC](https://help.nextcloud.com/t/nextcloud-aio-interface-behind-nginx-in-a-subfolder/207327/7 "2024-10-22T15:23:58Z")

</div>

> I do see support for `OVERWRITEWEBROOT` being passed as an environment variable in AIO [here](https://github.com/nextcloud/all-in-one/blob/026b1b87fa71d7c0f485b25c7bd0c4fcb24c6026/Containers/nextcloud/config/reverse-proxy.config.php#L12-L15). 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](https://github.com/nextcloud/all-in-one/tree/026b1b87fa71d7c0f485b25c7bd0c4fcb24c6026/Containers/mastercontainer)) 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

---

<div class="post-metadata">

**Author:** ![jtr](https://help.nextcloud.com/letter_avatar/jtr/32/5_5575768a8748004e209b776fc1b2916d.png) [@jtr](https://help.nextcloud.com/u/jtr)\
**Post date:** [October 22, 2024, 10:29pm UTC](https://help.nextcloud.com/t/nextcloud-aio-interface-behind-nginx-in-a-subfolder/207327/8 "2024-10-22T22:29:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![daks](https://help.nextcloud.com/user_avatar/help.nextcloud.com/daks/32/65638_2.png) [@daks](https://help.nextcloud.com/u/daks)\
**Post date:** [October 25, 2024, 5:23pm UTC](https://help.nextcloud.com/t/nextcloud-aio-interface-behind-nginx-in-a-subfolder/207327/9 "2024-10-25T17:23:15Z")

</div>

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](https://github.com/nextcloud/all-in-one/discussions/5480)

---

<div class="post-metadata">

**Author:** ![system](https://help.nextcloud.com/user_avatar/help.nextcloud.com/system/32/29333_2.png) [@system](https://help.nextcloud.com/u/system)\
**Post date:** [January 23, 2025, 5:23pm UTC](https://help.nextcloud.com/t/nextcloud-aio-interface-behind-nginx-in-a-subfolder/207327/10 "2025-01-23T17:23:29Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
