# Docker AIO with nginx reverse proxy on docker network

**URL:** <https://help.nextcloud.com/t/docker-aio-with-nginx-reverse-proxy-on-docker-network/173461>\
**Category:** ℹ️ Support\
**Tags:** reverseproxy, docker, nginx, docker-compose\
**Created:** [November 2, 2023, 1:21am UTC](https://help.nextcloud.com/t/docker-aio-with-nginx-reverse-proxy-on-docker-network/173461 "2023-11-02T01:21:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Numerlor](https://help.nextcloud.com/user_avatar/help.nextcloud.com/numerlor/32/55693_2.png) [@Numerlor](https://help.nextcloud.com/u/Numerlor)\
**Post date:** [November 2, 2023, 1:21am UTC](https://help.nextcloud.com/t/docker-aio-with-nginx-reverse-proxy-on-docker-network/173461/1 "2023-11-02T01:21:17Z")

</div>

I’ve been trying to get the aio container running behind nginx that’s running in a separate container, with both containers sharing a docker network with no luck.

[Installing NextCloud AIO behind a reverse proxy (nginx) with a Docker network - 🚧 Installation - Nextcloud community](https://help.nextcloud.com/t/installing-nextcloud-aio-behind-a-reverse-proxy-nginx-with-a-docker-network/169141) seems somewhat similar but it looks like they got through to the server and got an error there.

Going through the reverse-proxy tutorial I got these configs

```yml
version: "3.9"

services:
  cloud:
    container_name: "nextcloud-aio-mastercontainer"
    image: nextcloud/all-in-one:latest
    init: true
    restart: always

    ports:
      - "8000:8080"
    environment:
      - APACHE_PORT=11000
      - APACHE_IP_BINDING=0.0.0.0
    volumes:
      - nextcloud_aio_mastercontainer:/mnt/docker-aio-config
      - /var/run/docker.sock:/var/run/docker.sock:ro
    networks:
      - defnet

volumes:
  nextcloud_aio_mastercontainer:
    name: "nextcloud_aio_mastercontainer"

networks:
  defnet:
    name: defnet
    external: true

```

```auto
server {
    listen 443 ssl;
    server_name www.example.com;

    ssl_certificate /etc/certbot/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/certbot/live/example.com/privkey.pem;

    ssl_session_timeout 1d;
    ssl_session_cache shared:MozSSL:10m; # about 40000 sessions
    ssl_session_tickets off;

    location / {
        proxy_pass http://cloud:11000$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 Accept-Encoding "";
        proxy_set_header Host $host;

        client_body_buffer_size 512k;
        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;
    }
}

```

Where is the 11000 port supposed to be opened? Running docker ps it’s not exposed normally through docker, and trying netcap I got through to all the expected ports at the container’s ip except for 11000

Trying other hosts for the proxy\_pass also got me nothing

---

<div class="post-metadata">

**Author:** ![dugite-code](https://help.nextcloud.com/user_avatar/help.nextcloud.com/dugite-code/32/6434_2.png) [@dugite-code](https://help.nextcloud.com/u/dugite-code)\
**Post date:** [November 2, 2023, 2:41am UTC](https://help.nextcloud.com/t/docker-aio-with-nginx-reverse-proxy-on-docker-network/173461/2 "2023-11-02T02:41:05Z")

</div>

You’re exposing port 8000 but set the APACHE\_PORT to 11000 so that exposed port does nothing

```auto
    ports:
      - "8000:8080"
    environment:
      - APACHE_PORT=11000

```

You’ll need to verify that your Nginx container is a part of the `defnet` network. If it’s part of that network you don’t need to expose the APACHE\_PORT because they have access to anything in the same network.

One issue I had in my deployment was Nginx not resolving the internal domain ( `cloud` in your case `nextcloud_app` in mine). Setting the resolver in your Nginx to the docker `127.0.0.11` helped e.g.:

```auto
location / {
    resolver 127.0.0.11 valid=10s;
    set $upstream_app nextcloud_app;
    set $upstream_port 80;
    set $upstream_proto http;
    proxy_pass $upstream_proto://$upstream_app:$upstream_port;

  }

```

---

<div class="post-metadata">

**Author:** ![Numerlor](https://help.nextcloud.com/user_avatar/help.nextcloud.com/numerlor/32/55693_2.png) [@Numerlor](https://help.nextcloud.com/u/Numerlor)\
**Post date:** [November 2, 2023, 3:04am UTC](https://help.nextcloud.com/t/docker-aio-with-nginx-reverse-proxy-on-docker-network/173461/3 "2023-11-02T03:04:28Z")

</div>

Sorry the 8000 was a left over from me wanting to check if at least directly connecting works. nginx is working fine for all the other srvices through the docker domains so that’s working fine.

Shuold I just try to connect to 8080 if the APACHE\_PORT is not necessary?

Trying it now with just [https://cloud:8080/](https://cloud:8080/) I got

> Nextcloud AIO v7.5.1
> 
> ## Domaincheck container is not running
> 
> This is not expected. Most likely this happened because port 443 is already in use on your server. You can check the mastercontainer logs and domaincheck container logs for further clues. You should be able to resolve this by adjusting the APACHE\_PORT by following the **[reverse proxy documentation](https://github.com/nextcloud/all-in-one/blob/main/reverse-proxy.md)**. Advice: have a detailed look at the changed docker run command for AIO.

as nginx is running at 443

---

<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:** [November 2, 2023, 6:34am UTC](https://help.nextcloud.com/t/docker-aio-with-nginx-reverse-proxy-on-docker-network/173461/4 "2023-11-02T06:34:20Z")

</div>

Hi, can you follow [https://github.com/nextcloud/all-in-one/blob/main/reverse-proxy.md](https://github.com/nextcloud/all-in-one/blob/main/reverse-proxy.md)?

---

<div class="post-metadata">

**Author:** ![Numerlor](https://help.nextcloud.com/user_avatar/help.nextcloud.com/numerlor/32/55693_2.png) [@Numerlor](https://help.nextcloud.com/u/Numerlor)\
**Post date:** [November 2, 2023, 8:03am UTC](https://help.nextcloud.com/t/docker-aio-with-nginx-reverse-proxy-on-docker-network/173461/5 "2023-11-02T08:03:22Z")

</div>

Hi, I’ve tried to follow it but the steps for

> Running the Reverse Proxy in a Docker container on the same server

Didn’t get me anywhere, none of the docer internal ips I tried connected on the port, and I’d like to keep everything in the docker network instead of going through the host

---

<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:** [September 23, 2024, 1:41pm UTC](https://help.nextcloud.com/t/docker-aio-with-nginx-reverse-proxy-on-docker-network/173461/6 "2024-09-23T13:41:41Z")

</div>

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