Reverse Proxy Nginx -> Apache2 &Nextcloud

Nextcloud version :15.05
Operating system and version:Debian 9.5.1
Apache or nginx version : Apache 2.4.25
PHP version:7.3.3.1

The issue you are facing:

Hello,

I am currently trying to make my Nextcloud installation externally accessible via my existing reverse proxy. I would like to make the nextcloud accessible via my domain xyz.tld / nextcloud.

For this I have adapted the following in my reverse proxy configuration (Nginx):

Nextcloud

location / nextcloud {

proxy_pass http://192.168.1.212/nextcloud/;

proxy_redirect off;

proxy_set_header Host $ host;

proxy_set_header X-Real-IP $ remote_addr;

proxy_set_header X-Forwarded-For $

proxy_add_x_forwarded_for;

}

If I then adjust the configuration in the config.php.

config / config.php

// Overwrite rules

‘overwrite.cli.url’ => ‘http: // local ip-adress / nextcloud’,

// Proxy Rules

‘trusted_proxies’ => [‘ReverseProxyIP-Address’],

‘overwirtehost’ => ‘yxz.tld’,

‘overwritewebroot’ => ‘/ nextcloud’,

‘overwriteprotocol’ => ‘https’,

‘overwritecondaddr’ => ‘^ 000 \ .000 \ .0 \ .000 $’, (ReverseProxyIP address)

If this error appears when calling the page yxz.ltd/nextcloud:

internal server error

The server could not complete the request.
If this happens again, please send the following technical details to your server administrator.
Further details can be found in the server log.

Technical details
Remote Address: (public ip address of my router)
Request identifier: cryptic identifier

Is this the first time you’ve seen this error? (Y/N):Y

Steps to replicate it:

1.every time

The output of your Nextcloud log in Admin > Logging:


{"reqId":"3dGUhIiSQQyjtSx0MUVm","level":3,"time":"March 25, 2019 13:23:52","remoteAddr":"publicIP","user":"admin","app":"index","method":"GET","url":"\/nextcloud\/index.php\/apps\/files\/","message":{"Exception":"Exception","Message":"The requested uri(\/nextcloud\/index.php\/apps\/files\/) cannot be processed by the script '\/nextcloud\/\/index.php')","Code":0,"Trace":[{"file":"\/var\/www\/html\/nextcloud\/lib\/base.php","line":930,"function":"getRawPathInfo","class":"OC\\AppFramework\\Http\\Request","type":"->","args":[]},{"file":"\/var\/www\/html\/nextcloud\/index.php","line":42,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"\/var\/www\/html\/nextcloud\/lib\/private\/AppFramework\/Http\/Request.php","Line":784,"CustomMessage":"--"},"userAgent":"Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/73.0.3683.86 Safari\/537.36","version":"15.0.5.3"}

{"reqId":"IwGnz0jfdc0A2NKYZw3o","level":3,"time":"March 25, 2019 13:23:53","remoteAddr":" publicIP","user":"admin","app":"index","method":"GET","url":"\/nextcloud\/index.php\/apps\/files\/","message":{"Exception":"Exception","Message":"The requested uri(\/nextcloud\/index.php\/apps\/files\/) cannot be processed by the script '\/nextcloud\/\/index.php')","Code":0,"Trace":[{"file":"\/var\/www\/html\/nextcloud\/lib\/base.php","line":930,"function":"getRawPathInfo","class":"OC\\AppFramework\\Http\\Request","type":"->","args":[]},{"file":"\/var\/www\/html\/nextcloud\/index.php","line":42,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"\/var\/www\/html\/nextcloud\/lib\/private\/AppFramework\/Http\/Request.php","Line":784,"CustomMessage":"--"},"userAgent":"Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/73.0.3683.86 Safari\/537.36","version":"15.0.5.3"}

{"reqId":"lyUY8XJ2P1wClpnIjZil","level":3,"time":"March 25, 2019 13:23:53","remoteAddr":" publicIP","user":"admin","app":"index","method":"GET","url":"\/nextcloud\/index.php\/js\/core\/merged-template-prepend.js?v=f361828e-0","message":{"Exception":"Exception","Message":"The requested uri(\/nextcloud\/index.php\/js\/core\/merged-template-prepend.js) cannot be processed by the script '\/nextcloud\/\/index.php')","Code":0,"Trace":[{"file":"\/var\/www\/html\/nextcloud\/lib\/base.php","line":930,"function":"getRawPathInfo","class":"OC\\AppFramework\\Http\\Request","type":"->","args":[]},{"file":"\/var\/www\/html\/nextcloud\/index.php","line":42,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"\/var\/www\/html\/nextcloud\/lib\/private\/AppFramework\/Http\/Request.php","Line":784,"CustomMessage":"--"},"userAgent":"Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/73.0.3683.86 Safari\/537.36","version":"15.0.5.3"}```

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

<?php

$CONFIG = array (

‘instanceid’ => ‘ocsh00tscez0’,

‘passwordsalt’ => ‘1lE5NiBvaxfZ3qHdPQb#dyKdxZ2g9S’,

‘secret’ => ‘Yx7Djaa2Kv5lhJ69ysldsrTf5v4EEywqzowhSUP5Z8fafMC6uDGfkMu’,

‘trusted_domains’ =>

array (

0 => ‘localhost’,

1 => ‘localIP’,

2 => ‘yxz.ltf’,

),

‘datadirectory’ => ‘/var/www/html/nextcloud/data’,

‘dbtype’ => ‘mysql’,

‘version’ => ‘15.0.5.3’,

// Overwrite Regeln

‘overwrite.cli.url’ => ‘http://localIP/nextcloud’,

// Proxy Rules

‘trusted_proxies’ => [‘ReverseProxyIP’],

‘overwirtehost’ => ‘yxz.ltd’,

‘overwritewebroot’ => ‘/nextcloud’,

‘overwriteprotocol’ => ‘https’,

‘overwritecondaddr’ => ‘^000.000.000.000$’,

// Datenbank

‘dbname’ => ‘xyz’,

‘dbhost’ => ‘Database’,

‘dbport’ => ‘’,

‘dbtableprefix’ => ‘oc_’,

‘dbuser’ => ‘yxz’,

‘dbpassword’ => ‘Y5tKruEg9pN4ksafasfdgaF9z’,

‘installed’ => true,

); ```

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


Access.log

000.000.000.000- - [25/Mar/2019:13:36:57 +0000] &quot;GET /nextcloud/ocs/v2.php/apps/no tifications/api/v2/notifications HTTP/1.1&quot; 200 2208 &quot;-&quot; &quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Sa fari/537.36&quot;

000.000.000.000 - - [25/Mar/2019:13:36:39 +0000] &quot;GET /nextcloud/index.php/apps/log reader/poll?lastReqId=lyUY8XJ2P1wClpnIjZil HTTP/1.1&quot; 200 874 &quot;-&quot; &quot;Mozilla/5.0 (W indows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3 683.86 Safari/537.36&quot;

000.000.000.000- - [25/Mar/2019:13:36:59 +0000] &quot;GET /nextcloud/index.php/apps/log reader/poll?lastReqId=lyUY8XJ2P1wClpnIjZil HTTP/1.1&quot; 200 874 &quot;-&quot; &quot;Mozilla/5.0 (W indows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3 683.86 Safari/537.36&quot;

Error.log

[Mon Mar 25 13:27:57.528046 2019] [authz_core:error] [pid 5191] [client 000.000.000.000:56228] AH01630: client denied by server configuration: /var/www/html/nextcloud/data/.ocdata