Nginx-reverseproxy and nextcloud issue

Is nextcloud reachable via the local ip?


http://nextcloud is not.
neither nextcloud:90 nor https
nothing on
localhost:90

I also tried the other container names, and nothing…


image

Docker creates a private network for container(s) (unless you specify host networking). You could find out what the IPs are with docker inspect on a running container but then your setup is kinda dependent on whatever those might be and it probably will change next time you update the container(s). The way docker solved this is by having container names resolve to their private IPs within the docker network they are in.

His containers should already all be in the same docker network.

So nextcloud should be working for the upstream ip in his setup rn. Lots of nextcloud in there…

Please tell me you are not using docker in windows server directly, which makes a virtual machine in hyperv to run a linux vm.

Whatever linux is running in a vm or something else, will have an ip and you will need to point nginx to it. How are you docker networks setup?

If it is linux in a vm, localhost won’t work, try the ip of th VM with :90 and see if that works?

Yes, but no you don’t need to know the VMs IP for anything here.

There is a compose file somewhere here. Not sure where the website went it’s probably in the linuxserver.io/swag container. But yeah that thing and a couple of nextcloud associated containers.

version: '3.3'

volumes:
    nextcloud:

services:
  reverseproxy:
    image: linuxserver/swag
    container_name: reverseproxy
    restart: unless-stopped
    ports:
      - "80:80"
      - "9090:443"
    environment:
      - VALIDATION=http
      - URL=abyss.fi
      - PUID=1000
      - PGID=1000
      - TZ=Europe/London
      - SUBDOMAINS=www,cc,zd
    volumes:
      - ./src/path/to/config:/config:rw
    cap_add:
      - NET_ADMIN
  db:
    image: mariadb
    environment:
        - MYSQL_ROOT_PASSWORD=msrpw
        - MYSQL_PASSWORD=mspw
        - MYSQL_DATABASE=nextcloud
        - MYSQL_USER=msu
    volumes: 
        - ./mysql:/var/lib/mysql
    restart: unless-stopped
    
  nextcloud:
    container_name: nextcloud
    image: nextcloud:fpm
    ports:
        - 90:80
    volumes:
        - nextcloud:/var/www/html
        - ./app/data:/var/www/html/data
        - ./app/config:/var/www/html/config
    restart: unless-stopped

  cron:
    image: rcdailey/nextcloud-cronjob
    environment:
        - NEXTCLOUD_CRON_MINUTE_INTERVAL=15
        - NEXTCLOUD_CONTAINER_NAME=nextcloud
    volumes:
        - /var/run/docker.sock:/var/run/docker.sock:ro
        - /etc/localtime:/etc/localtime:ro
    restart: always

upstream nextcloud {
    server nextcloud;
}

server {
    listen       80;
    listen       443 ssl http2;
    server_name  nextcloud;
    # Max allowed upload file in web page
    client_max_body_size 20G;
    if ($server_port !~ 443){
        rewrite ^(/.*)$ https://$host$1 permanent;
    }

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    location = /.well-known/carddav {
      return 301 $scheme://$host/remote.php/dav;
    }
    location = /.well-known/caldav {
      return 301 $scheme://$host/remote.php/dav;
    }

    # Enable gzip compression
    gzip on;
    gzip_vary on;
    gzip_comp_level 4;
    gzip_min_length 256;
    gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
    gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy;

    # redirection and disable to access backend sensitive folders and resources
    location / {
        rewrite ^ /index.php$request_uri;
    }

    location ~ ^\/(?:build|tests|config|lib|3rdparty|templates|data)\/ {
        deny all;
    }
    location ~ ^\/(?:\.|autotest|occ|issue|indie|db_|console) {
        deny all;
    }

    location ~ ^\/(?:updater|ocs-provider)(?:$|\/) {
        try_files $uri/ =404;
        index index.php;
    }

    location ~ \.(?:css|js|woff2?|svg|gif)$ {
        try_files $uri /index.php$request_uri;
        add_header Cache-Control "public, max-age=15778463";
        add_header X-Content-Type-Options nosniff;
        add_header X-XSS-Protection "1; mode=block";
        add_header X-Robots-Tag none;
        add_header X-Download-Options noopen;
        add_header X-Permitted-Cross-Domain-Policies none;
        add_header Referrer-Policy no-referrer;
        access_log off;
    }

    location ~ \.(?:png|html|ttf|ico|jpg|jpeg)$ {
        try_files $uri /index.php$request_uri;
        # Optional: Don't log access to other assets
        access_log off;
    }
    'trusted_proxies' => ['reverseproxy'],
    'overwrite.cli.url' => 'https://cc.abyss.fi/',
    'overwritehost' => 'cc.abyss.fi',
    'overwriteprotocol' => 'https',
}

Been looking at all these three for hours. I have no clue what I missed.

server_name  nextcloud;

This should be the sub domain you want nextcloud to be reachable from not nextcloud. Not sure why you changed that.

I feel like we are going over the same things a million times …

1 Like

I checked if nextcloud would work there in place.

I completely rebuilt the container. (with cc.abyss.fi in the config)

Still the top domain page instead of the nextcloud page.

I’m really up for a teamviewer/teams/discord session if someone would like to check this…

Can you access nextcloud directly without SSL?

We are looking at the nginx config for the swag container and not something inside the nextcloud one right?

If it is then this

location / {
        rewrite ^ /index.php$request_uri;
    }

does not make any sense you are returning some local index site right there it should proxy to the nextcloud not provide a site of its own.

What @Novasty wrote essentially.

location / {
        proxy_pass http://nextcloud;
    }

That config file is nextcloud.conf inside
nginx-swag\src\conf.d

This is the old compose file from the guide you followed

version: '3'

volumes:
    letsencrypt:
    nextcloud:

services: 
    proxy:
        image: staticfloat/nginx-certbot
        ports:
            - 80:80
            - 443:443
        environment: 
            CERTBOT_EMAIL: [email protected]
            ENVSUBST_VARS: FQDN
            FQDN: nextcloud.51sec.org
        volumes:
            - ./conf.d:/etc/nginx/user.conf.d:ro
            - letsencrypt:/etc/letsencrypt
            - nextcloud:/var/www/html
        restart: unless-stopped

    db:
        image: mariadb
        environment:
            - MYSQL_ROOT_PASSWORD=Password1234!@
            - MYSQL_PASSWORD=Password1234!@
            - MYSQL_DATABASE=nextcloud
            - MYSQL_USER=nextcloud
        volumes: 
            - ./mysql:/var/lib/mysql
        restart: unless-stopped
    
    app:
        image: nextcloud:fpm
        volumes:
            - nextcloud:/var/www/html
            - ./app/data:/var/www/html/data
            - ./app/config:/var/www/html/config
        restart: unless-stopped

    cron:
        image: rcdailey/nextcloud-cronjob
        environment:
            - NEXTCLOUD_CRON_MINUTE_INTERVAL=15
            - NEXTCLOUD_CONTAINER_NAME=app
            - NEXTCLOUD_PROJECT_NAME=nextcloud
        volumes:
            - /var/run/docker.sock:/var/run/docker.sock:ro
            - /etc/localtime:/etc/localtime:ro
        restart: always

staticfloat/nginx-certbot does something similar to the swag image. So, yeah it appears we are not reverse proxying anything it itself is hosting the site. There is this mount in your nextcloud service nextcloud:/var/www/html and the same mount up in the proxy. So the root for webpages from the swag container is by default configured to be /config/www.

Add another mount to the swag container

    volumes:
      - ./src/path/to/config:/config:rw
      - nextcloud:/config/www

See if nextcloud works then. Would be better to mount to /config/html/nextcloud since you are gonna have multiple things to host.

Still nothing.
image

nextcloud:
    container_name: nextcloud
    image: nextcloud:fpm
    ports:
        - 90:80
    volumes:
        - nextcloud:/var/www/html

Where is the ‘nextcloud’ directory on your host from ‘nextcloud:/var/www/html’ is there anything in there? That’s the one you need to mount to the swag container. Also mount it to /config/www for now not /config/www/nextcloud since otherwise you need to also change nginx site root for that config.

1 Like

Might have been smarter for you to use nextcloud:apache and not nextcloud:fpm as it comes with a webserver just does not do SSL still much less to configure. Configuration seems to be a problem (obviously).

Then what @Novasty provided would have worked for the proxy. Now it’s not really a proxy it’s doing everything there is to do and the nextcloud:fpm container is more like a glorified storage unit.

Just something else you can try if you can’t get it to work like this.

Well, tbh, I don’t know where that is.

AND WHAT, it worked well somewhat, check the link.

cc.abyss.fi

Well… do what it sais lul

It´s important to know where to folders are those are essentially your nextcloud installation if you loose them and need to migrate or whatever your nextcloud is gone.

image
Well it is there… I restarted the whole container. Still gives me the error.

SSH into the nextcloud container find the file and run chown www-data:www-data CAN_INSTALL.

I wonder why a button wasn’t enough confirmation for them.

image
something like this you mean?
image

No open PowerShell

docker exec -it <container_name> /bin/bash