Nextcloud not reachable via mobile app

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version: 19.0.0
Operating system and version: Linux 4.19.107-Unraid x86_64
Apache or nginx version: 1.18.0
PHP version: 7.3.18

The issue you are facing: Nextcloud not reachable via mobile app nor security scan website but it’s reachable just fine through web browser.

Is this the first time you’ve seen this error?: Yes

Steps to replicate it:

  1. Try to add my nextcloud to mobile app.

The output of your Nextcloud log in Admin > Logging:

No relevant logs, last log from 2h ago.

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'datadirectory' => '/data',
  'instanceid' => 'xxx',
  'passwordsalt' => 'xxx',
  'secret' => 'xxx',
  'trusted_domains' => 
  array (
    0 => '192.168.1.5',
    1 => 'xxx',
    2 => 'xxx',
  ),
  'dbtype' => 'sqlite3',
  'version' => '19.0.0.12',
  'overwrite.cli.url' => 'https://192.168.1.5',
  'installed' => true,
);

The output of your Apache/nginx/system log in /var/log/____:

192.168.1.10 - - [10/Jun/2020:11:19:03 +0200] "GET /apps/logreader/poll?lastReqId=Z1nXwYLAHcuzUWVMBNB9 HTTP/1.0" 200 2 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36"
192.168.1.10 - - [10/Jun/2020:11:19:15 +0200] "GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/1.0" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36"
192.168.1.10 - - [10/Jun/2020:11:19:23 +0200] "GET /apps/logreader/poll?lastReqId=Z1nXwYLAHcuzUWVMBNB9 HTTP/1.0" 200 2 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36"
192.168.1.10 - - [10/Jun/2020:11:19:43 +0200] "GET /apps/logreader/poll?lastReqId=Z1nXwYLAHcuzUWVMBNB9 HTTP/1.0" 200 2 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36"
192.168.1.10 - - [10/Jun/2020:11:19:45 +0200] "GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/1.0" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36"
192.168.1.10 - - [10/Jun/2020:11:20:04 +0200] "GET /apps/logreader/poll?lastReqId=Z1nXwYLAHcuzUWVMBNB9 HTTP/1.0" 200 2 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36"

Please describe IN DETAIL which kind of tests you’ve run, from your LAN using cable or wifi, over the internet, if it’s an ipv4 or ipv6 connection, if the DNS resolution works or if you try to use an ip address, etc., etc.

Sorry for not writing this in detail. I tested it once again and it turns out mobile app only works locally via IP. It doesn’t work when I try to reach it via its external address no matter if i’m on wifi or mobile data. Same is with the Nextcloud security scan, https://scan.nextcloud.com/ it says that there is no nextcloud running.
Still, In the web browser nextcloud loads normally no matter the network or address used.

To explain my setup a bit more: Nextcloud is in Docker on my Unraid NAS with ip 192.168.1.5 (mobile app works locally) > after that it’s reverse proxied from ubuntu-VM on 192.168.1.10 (mobile app can’t reach freenas on this IP locally) > Ubuntu-VM is linked via OpenVPN to my VPS box > VPS box is open to internet and is port forwarding it the Ubuntu-VM.

Nginx configuration on Ubuntu-VM:

    location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass https://192.168.1.5:443;

You can not reach local ip 192.168… from internet. You must configure dyndns, porforwarding and lets encrypt.

Very funny. Did you even read what I said?
Nextcloud IS reachable via internet. I didn’t put my external IP and domain here for privacy reasons.

Hello,
Relevants log are in /var/log/nginx/error.log
Can you display this ?

Not good example ip :wink:
ip or name in real :wink:
server in internet or at home?
dyndns?

Thank you for pointing me in the right direction. I checked the nginx logs on the ubuntu-VM i use to port forward and there was this log repeated few times:

2020/06/11 07:56:41 [error] 1157#1157: *3244 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 95.217.53.149, server: xxx, request: "GET /nextcloud/status.php HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.4-fpm.sock:", host: "xxx"

I also run Pihole on this nginx so I had FastCGI settings configured for it but it turns out it collided with nextcloud. I had to nest the fastcgi options inside pihole location as so:

#Nextcloud
location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass https://192.168.1.5:443;
    }
#pihole
    location /admin {
        root /var/www/html;
        index index.php index.html index.htm;
        location ~ \.php$ {
                root /var/www/html;
                include fastcgi_params;
                fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
                fastcgi_pass unix:/run/php/php7.4-fpm.sock;
                fastcgi_param FQDN true;
        }
    }