Nginx/FPM on different servers

Nextcloud version: 16.0.3.0
Operating system and version: Ubuntu 18.04.2 LTS / Debian 9
Nginx version: 1.10.3
PHP version: 7.2.19


Hi there!

I’m trying to setup my nextcloud instance with an nginx on another server than the one running the FPM instance.

If I run an nginx instance on the same server than the FPM, everything works fine: FPM listens to on port 9001, nginx server upstream is set to 127.0.1.1:9001, works like a charm.

If I set my nginx instance on another server, and this one has its upstream set to fpm.ipa.ddr.ess:9001, then the page loads, but all assets (js/css/images) returns a HTTP 302 with a Location Header to /login. I presume it’s an issue in my nginx config on the assets blocks, but I can’t figure out where.

I use the Nginx config available at https://docs.nextcloud.com/server/16/admin_manual/installation/nginx.html.

Does anyone tried it before?

Cheers!


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

config.php file:

<?php
$CONFIG = array (
  'passwordsalt' => '***',
  'secret' => '***',
  'trusted_domains' => 
  array (
    0 => 'localhost',
    1 => 'cloud.***.***',
    3 => '192.168.204.35',
  ),
  'datadirectory' => '/data/nextcloud',
  'dbtype' => 'pgsql',
  'version' => '16.0.3.0',
  'overwrite.cli.url' => 'https://cloud.***.***',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'nextcloud',
  'dbpassword' => '***',
  'installed' => true,
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'updater.release.channel' => 'beta',
  'maintenance' => false,
  'data-fingerprint' => '4a220891e1376be9534a75af49be88af',
  'instanceid' => 'oc5dvn2e5pqg',
  'mail_smtpmode' => 'smtp',
  'mail_smtpsecure' => 'tls',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => 'postmaster',
  'mail_domain' => '***.***',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpauth' => 1,
  'mail_smtphost' => 'smtp.***.***',
  'mail_smtpport' => '587',
  'mail_smtpname' => 'postmaster@***.***',
  'mail_smtppassword' => '***',
  'loglevel' => 2,
);

/var/log/nginx/access.log:

192.168.204.221 - - [03/Aug/2019:13:08:55 +0200] "GET /login HTTP/2.0" 200 4705 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0"
192.168.204.221 - - [03/Aug/2019:13:08:56 +0200] "GET /apps/files_videoplayer/js/main.js?v=14a62deb-0 HTTP/2.0" 302 663 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0"
192.168.204.221 - - [03/Aug/2019:13:08:56 +0200] "GET /core/js/dist/main.js?v=14a62deb-0 HTTP/2.0" 302 663 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0"
192.168.204.221 - - [03/Aug/2019:13:08:56 +0200] "GET /apps/files_pdfviewer/js/previewplugin.js?v=14a62deb-0 HTTP/2.0" 302 663 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0"
192.168.204.221 - - [03/Aug/2019:13:08:56 +0200] "GET /apps/files_ebookreader/js/previewplugin.js?v=14a62deb-0 HTTP/2.0" 302 664 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0"
192.168.204.221 - - [03/Aug/2019:13:08:57 +0200] "GET /login HTTP/2.0" 200 4709 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0"
192.168.204.221 - - [03/Aug/2019:13:08:57 +0200] "GET /login HTTP/2.0" 200 4710 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0"
192.168.204.221 - - [03/Aug/2019:13:08:57 +0200] "GET /core/js/files/fileinfo.js?v=14a62deb-0 HTTP/2.0" 302 662 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0"
192.168.204.221 - - [03/Aug/2019:13:08:57 +0200] "GET /apps/theming/styles?v=0 HTTP/2.0" 200 1168 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0"
192.168.204.221 - - [03/Aug/2019:13:08:57 +0200] "GET /apps/files_ebookreader/css/style.css?v=25e64aa7-0 HTTP/2.0" 302 663 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0"
192.168.204.221 - - [03/Aug/2019:13:08:57 +0200] "GET /core/css/guest.css?v=14a62deb-0 HTTP/2.0" 302 662 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0"
192.168.204.221 - - [03/Aug/2019:13:08:57 +0200] "GET /login HTTP/2.0" 200 4706 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0"
192.168.204.221 - - [03/Aug/2019:13:08:57 +0200] "GET /core/js/dist/share_backend.js?v=14a62deb-0 HTTP/2.0" 302 662 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0"
192.168.204.221 - - [03/Aug/2019:13:08:57 +0200] "GET /login HTTP/2.0" 200 4706 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0"
192.168.204.221 - - [03/Aug/2019:13:08:58 +0200] "GET /js/core/merged-login.js?v=14a62deb-0 HTTP/2.0" 200 3205 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0"
192.168.204.221 - - [03/Aug/2019:13:08:58 +0200] "GET /login HTTP/2.0" 200 4711 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0"
192.168.204.221 - - [03/Aug/2019:13:08:58 +0200] "GET /login HTTP/2.0" 200 4711 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0"
192.168.204.221 - - [03/Aug/2019:13:08:58 +0200] "GET /core/search/js/search.js?v=14a62deb-0 HTTP/2.0" 302 663 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0"
192.168.204.221 - - [03/Aug/2019:13:08:58 +0200] "GET /apps/files_pdfviewer/css/style.css?v=35c36e89-0 HTTP/2.0" 302 662 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0"
192.168.204.221 - - [03/Aug/2019:13:08:58 +0200] "GET /apps/deck/css/activity.css?v=681b20c9-0 HTTP/2.0" 302 663 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0"
192.168.204.221 - - [03/Aug/2019:13:08:58 +0200] "GET /apps/files_rightclick/js/script.js?v=14a62deb-0 HTTP/2.0" 302 662 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0"
192.168.204.221 - - [03/Aug/2019:13:08:58 +0200] "GET /js/core/merged-template-prepend.js?v=14a62deb-0 HTTP/2.0" 200 24032 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0"
192.168.204.221 - - [03/Aug/2019:13:08:59 +0200] "GET /login HTTP/2.0" 200 4705 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0"
192.168.204.221 - - [03/Aug/2019:13:08:59 +0200] "GET /core/js/files/client.js?v=14a62deb-0 HTTP/2.0" 302 660 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0"
192.168.204.221 - - [03/Aug/2019:13:08:59 +0200] "GET /login HTTP/2.0" 200 4706 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0"
192.168.204.221 - - [03/Aug/2019:13:08:59 +0200] "GET /core/search/js/searchprovider.js?v=14a62deb-0 HTTP/2.0" 302 659 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0"
192.168.204.221 - - [03/Aug/2019:13:08:59 +0200] "GET /core/img/loading-dark.gif HTTP/2.0" 302 662 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0"
192.168.204.221 - - [03/Aug/2019:13:08:59 +0200] "GET /login HTTP/2.0" 200 4704 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0"
192.168.204.221 - - [03/Aug/2019:13:08:59 +0200] "GET /login HTTP/2.0" 200 4708 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0"
192.168.204.221 - - [03/Aug/2019:13:08:59 +0200] "GET /login HTTP/2.0" 200 4707 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0"
192.168.204.221 - - [03/Aug/2019:13:09:00 +0200] "GET /login HTTP/2.0" 200 4702 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0"
192.168.204.221 - - [03/Aug/2019:13:09:00 +0200] "GET /login HTTP/2.0" 200 4710 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0"
192.168.204.221 - - [03/Aug/2019:13:09:00 +0200] "GET /login HTTP/2.0" 200 4711 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0"
192.168.204.221 - - [03/Aug/2019:13:09:00 +0200] "GET /apps/theming/js/theming?v=0 HTTP/2.0" 200 940 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0"
192.168.204.221 - - [03/Aug/2019:13:09:00 +0200] "GET /apps/accessibility/js/accessibility?v=0 HTTP/2.0" 200 771 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0"
192.168.204.221 - - [03/Aug/2019:13:09:00 +0200] "GET /login HTTP/2.0" 200 4710 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0"
192.168.204.221 - - [03/Aug/2019:13:09:00 +0200] "GET /svg/core/logo/logo?color=fff&v=1 HTTP/2.0" 200 905 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0"
192.168.204.221 - - [03/Aug/2019:13:09:00 +0200] "GET /core/img/favicon-touch.png HTTP/2.0" 302 663 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0"
192.168.204.221 - - [03/Aug/2019:13:09:01 +0200] "GET /core/img/favicon.ico HTTP/2.0" 302 662 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0"
192.168.204.221 - - [03/Aug/2019:13:09:01 +0200] "GET /login HTTP/2.0" 200 4710 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0"
192.168.204.221 - - [03/Aug/2019:13:09:01 +0200] "GET /login HTTP/2.0" 200 4704 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0"

is the content of /var/www/html/nextcloud (the content of the archive you download from nextcloud) available to nginx?

if not make it so.

(btw if you just unarchive nextcloud on your nginx machine think about your update strategy.)

yes. if you run nextcloud in containers it’s the same situation. and /var/www/html is a shared volume among the the container. :wink:

Gotcha! I didn’t expose the nextcloud files to the nginx frontend, I early presumed that every calls run through the index.php file. Works great with the directory mounted using NFS readonly in the nginx server.

Thanks!