Hello all. I have been running a nextcloud server behind an nginx proxy for a while now, but just started running into issues after I had to reconfigure things since I moved and got a new router. I am running my proxy and nextcloud server on a TrueNAS machine. I’ve been having super weird behavior which has made nailing down my problem quite difficult. I have typically been able to access nextcloud using it’s IP address through both HTTP and HTTPS, however when I try to connect via domain name (which is directed to the reverse proxy), sometimes it will connect but most of the time it won’t connect at all. There are sometime that it will connect through the domain via HTTP but not HTTPS. Sometimes it won’t connect through either the domain or the IP address and I haven’t been able to identify much rhyme or reason to when it will and won’t work. Here are my config files for both Nginx and Nextcloud (with some details redacted):
NGINX
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
client_max_body_size 16G;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
listen 443 ssl;
server_name nextcloud.mywebsite.com;
ssl_certificate /path/to/cert/fullchain.pem;
ssl_certificate_key /path/to/cert/privkey.pem;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
client_max_body_size 16G;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
#root /usr/local/www/nextcloud/;
#index index.php;
proxy_pass https://x.x.x.71;
proxy_hide_header Upgrade;
proxy_buffering off;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/local/www/nginx-dist;
}
}
# virtual server for another HTTPS webapp
#
server {
listen 80;
listen 443;
server_name two.mywebsite.com;
location / {
proxy_pass https://x.x.x.81;
}
}
}
NEXTCLOUD
<?php
$CONFIG = array (
'apps_paths' =>
array (
0 =>
array (
'path' => '/usr/local/www/nextcloud/apps',
'url' => '/apps',
'writable' => true,
),
1 =>
array (
'path' => '/usr/local/www/nextcloud/apps-pkg',
'url' => '/apps-pkg',
'writable' => false,
),
),
'logfile' => '/var/log/nextcloud/nextcloud.log',
'memcache.local' => '\\OC\\Memcache\\APCu',
'one-click-instance' => true,
'one-click-instance.user-limit' => 100,
'memcache.distributed' => '\\OC\\Memcache\\Redis',
'memcache.locking' => '\\OC\\Memcache\\Redis',
'redis' =>
array (
'host' => 'localhost',
),
'passwordsalt' => 'xxxxx',
'secret' => 'xxxxxx',
'trusted_domains' =>
array (
0 => 'localhost',
1 => 'x.x.x.69',
2 => 'nextcloud.mywebsite.com',
),
'datadirectory' => '/usr/local/www/nextcloud/data',
'dbtype' => 'mysql',
'version' => '23.0.3.2',
'trusted_proxies' =>
array (
0 => 'x.x.x.70', #address of nginx proxy
),
'dbname' => 'nextcloud',
'dbhost' => 'localhost',
'dbport' => '',
'dbtableprefix' => 'oc_',
'mysql.utf8mb4' => true,
'dbuser' => 'oc_ncadmin',
'dbpassword' => 'xxxxxx',
'installed' => true,
'instanceid' => 'xxxxxx',
'maintenance' => false,
'updater.secret' => 'xxxxxxx',
);
For context, the other site that nginx is passing to (“two.mywebsite.com”) works just fine so the issue is somewhere in my configuration for nextcloud, either in nginx or in nextcloud itself.
If anybody has any suggestions or insight I would greatly appreciate it. I feel like I have tried everything and am at my wits end.