Прошу помощи. Nginx Nextcloud = 404 :С

Всем доброго врменени суток!

На веб сервере есть несколько сервисов, zabbix, phpmyadmin, wordpress и NEXTCLOUD.
С текущими настройками все сервисы кроме NEXTCLOUD работают (и внутри сети по 192.168.1.111 и через ssl по домену limewax.ru. Все прописано на стандартных портах 80 + ssl на 443. Вот конфиг Nginx:

server {

	listen 80 default_server;
	listen [::]:80 default_server;

	server_name www.limewax.ru limewax.ru;

        index index.php index.html index.htm index.nginx-debian.html;

        root /var/www/;

	if ($host = www.limewax.ru) {
		return 301 https://$host$request_uri;
	}


	if ($host = limewax.ru) {
		return 301 https://$host$request_uri;
	}

	location / {
		# First attempt to serve request as file, then
		# as directory, then fall back to displaying a 404.
		try_files $uri $uri/ =404;
	}

	# pass PHP scripts to FastCGI server
	location ~ \.php$ {
		include snippets/fastcgi-php.conf;
	# With php-fpm (or other unix sockets):
		fastcgi_pass unix:/run/php/php8.1-fpm.sock;
	# With php-cgi (or other tcp sockets):
	#	fastcgi_pass 127.0.0.1:9000;
	}
}

server {

	listen [::]:443 ssl ipv6only=on; # managed by Certbot
	listen 443 ssl; # managed by Certbot
	ssl_certificate /etc/letsencrypt/live/limewax.ru/fullchain.pem; # managed by Certbot
	ssl_certificate_key /etc/letsencrypt/live/limewax.ru/privkey.pem; # managed by Certbot
	include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
	ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

	root /var/www/;

	index index.php index.html index.htm index.nginx-debian.html;

	server_name www.limewax.ru limewax.ru;

	location / {
		# First attempt to serve request as file, then
		# as directory, then fall back to displaying a 404.
		try_files $uri $uri/ =404;
	}

	# pass PHP scripts to FastCGI server
	location ~ \.php$ {
		include snippets/fastcgi-php.conf;
	# With php-fpm (or other unix sockets):
		fastcgi_pass unix:/run/php/php8.1-fpm.sock;
	# With php-cgi (or other tcp sockets):
	#	fastcgi_pass 127.0.0.1:9000;
	}
}

И конфигурация NEXTCLOUD:

<?php
$CONFIG = array (
  'instanceid' => '********************************',
  'passwordsalt' => '******************************',
  'secret' => '************************************',
  'trusted_domains' => 
  array (
    0 => '192.168.1.111',
    1 => 'limewax.ru',
  ),
  'datadirectory' => '/usr/share/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '25.0.4.1',
  'overwrite.cli.url' => 'https://limewax.ru/nextcloud',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost:3306',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => '**********',
  'installed' => true,
);

Если я бегу limewax.ru/nextcloud
я получаю 404 здесь:
https://limewax.ru/nextcloud/index.php/login

Если по внутр.ip: 192.168.1.111/nextcloud
я получаю 404 здесь:
http://192.168.1.111/nextcloud/index.php/apps/dashboard/

Я хочу иметь доступ к NEXTCLOUD и по 80 и по 443 порту
для 443 через доменноеимяТОЧКАру
для 80 по внутр.IP

Может я что-то не понимаю или неправильно объясняю, прошу помочь и объяснить мне, где я ошибаюсь и что делаю не так.
Большое спасибо за любую помощь!

hello @Limewax welcome to the forum :handshake:

you likely missing all/some config.php settings related to hosting Nextcloud behind reverse proxy. Please review reverse proxy configuration likely it works if you add overwrite* parameters to your config.php

it’s always bad idea to access the system with different URLs/local IP. I recommend you to use “split-brain DNS” or “split-horizon DNS” so you can access local resources using public DNS name and https/TLS. Following this advice simplifies configuration and troubleshooting as you don’t need to maintain different configs for local and remote access:

https://github.com/nextcloud/all-in-one#how-can-i-access-nextcloud-locally

Hey @wwe!! Thanks for the quick response and help.
But I’m still having a hard time setting it up.
As far as I understand, the reverse proxy needs to be configured on the web server as well. Or i need have proxyserver like “squid” for this.
The documentation asks to specify overwritehost, overwriteprotocol, overwritewebroot, overwritecondaddr in the settings.

and enable this in nginx for redirect

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

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

when i change

'trusted_domains' =>
  array (
    0 => '192.168.1.111',
    1 => 'limewax.ru',

on

'trusted_domains' => 'limewax.ru',

it says “Access through untrusted domain”

Maybe i has wrong but earlier i configured everything without reverse proxy, but i wasnt my domain and ssl, i have only my static IP.

Maybe it’s important, but I ran into this problem after setting up Nextcloud and creating an admin account. Immediately after specifying the data about the database and account, I always get either 404 or an untrusted domain with different settings

with 404, I see that he is trying to look after the index.php path to the “app” directory, but apparently he cannot see it

Sorry for my bad understanding something(

as long I get your setup right you have nginx reverse proxy in front of your Nextcloud application (native, docker etc…).

for such setup you need nginx to provide right http header x-forwarded-for, x-real-ip etc… and Nextcloud application must trust this headers from (trusted_proxies) so the application knows the request doesn’t come from {reverse proxy} and was originally send to {trusted_domain}

means your Nextcloud application doesn’t understand the request was originally send to {trusted domain}…

I still don’t fully understand your setup… but maybe this WIKI helps you to find good starting point Apache Docker behind reverse proxy

1 Like