I’m trying to get NC28 to work on my Ubuntu 22.04 server using nginx. Have fallowed the guide for nginx, after initial setup I’m redirected to https://cloud.mydomainname.com/index.php/apps/dashboard/ and I get a 404 error.
I have set my domain in the configs, have set permissions to the root folder on NC, have done and linked my ssl cert, installed and enabled php8.2 (tested with a test file under nextcloud’s root and php8.2 is working fine at cloud.mydomainname.com/test.php).
PS ‘mydomainname’ is not my real domain, I have it set to my real domain in the configs, don’t want to share my real domain.
If I try to connect with my IP I get Access through untrusted domain.
I’ll link my configs:
config.php
<?php
$CONFIG = array (
'instanceid' => 'some-numbers-and-letters',
'passwordsalt' => 'some-numbers-and-letters',
'secret' => 'some-numbers-and-letters',
'trusted_domains' =>
array (
0 => 'cloud.mydomainname.com',
),
'datadirectory' => '/var/www/nextcloud/data',
'dbtype' => 'mysql',
'version' => '28.0.3.2',
'overwrite.cli.url' => 'https://cloud.mydomainname.com',
'dbname' => 'nextcloud',
'dbhost' => 'localhost',
'dbport' => '',
'dbtableprefix' => 'oc_',
'mysql.utf8mb4' => true,
'dbuser' => 'georgi-nextcloud',
'dbpassword' => 'thepasswordIuse',
'installed' => true,
'overwriteprotocol' => 'https',
);
/etc/nginx/sites-available/nextcloud
upstream php-handler {
#server 127.0.0.1:9000;
server unix:/run/php/php8.2-fpm.sock;
}
# Set the `immutable` cache control options only for assets with a cache busting `v` argument
map $arg_v $asset_immutable {
"" "";
default ", immutable";
}
server {
listen 80;
listen [::]:80;
server_name cloud.mydomainname.com;
# Prevent nginx HTTP Server Detection
server_tokens off;
# Enforce HTTPS
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name cloud.mydomainname.com;
# Path to the root of your installation
root /var/www/nextcloud/;
# Use Mozilla's guidelines for SSL/TLS settings
# https://mozilla.github.io/server-side-tls/ssl-config-generator/
ssl_certificate /etc/ssl/nginx/cloud.mydomainname.com.crt;
ssl_certificate_key /etc/ssl/nginx/cloud.mydomainname.com.key;
(ps, permissions and everything is set for the keys. This ps line is not in the config :D )
# Prevent nginx HTTP Server Detection
server_tokens off;
# HSTS settings
# WARNING: Only add the preload option once you read about
# the consequences in https://hstspreload.org/. This option
# will add the domain to a hardcoded list that is shipped
# in all major browsers and getting removed from this list
# could take several months.
#add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload" always;
# set max upload size and increase upload timeout:
client_max_body_size 512M;
client_body_timeout 300s;
fastcgi_buffers 64 4K;
# Enable gzip but do not remove ETag headers
gzip on;
gzip_vary on;
gzip_comp_level 4;
gzip_min_length 256;
gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
gzip_types application/atom+xml text/javascript application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/wasm applica>
# Pagespeed is not supported by Nextcloud, so if your server is built
# with the `ngx_pagespeed` module, uncomment this line to disable it.
#pagespeed off;
# The settings allows you to optimize the HTTP2 bandwidth.
# See https://blog.cloudflare.com/delivering-http-2-upload-speed-improvements/
# for tuning hints
client_body_buffer_size 512k;
# HTTP response headers borrowed from Nextcloud `.htaccess`
add_header Referrer-Policy "no-referrer" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Permitted-Cross-Domain-Policies "none" always;
add_header X-Robots-Tag "noindex, nofollow" always;
add_header X-XSS-Protection "1; mode=block" always;
# Remove X-Powered-By, which is an information leak
fastcgi_hide_header X-Powered-By;
# Set .mjs and .wasm MIME types
# Either include it in the default mime.types list
# and include that list explicitly or add the file extension
# only for Nextcloud like below:
include mime.types;
types {
text/javascript js mjs;
application/wasm wasm;
}
# Specify how to handle directories -- specifying `/index.php$request_uri`
# here as the fallback means that Nginx always exhibits the desired behaviour
# when a client requests a path that corresponds to a directory that exists
# on the server. In particular, if that directory contains an index.php file,
# that file is correctly served; if it doesn't, then the request is passed to
# the front-end controller. This consistent behaviour means that we don't need
# to specify custom rules for certain paths (e.g. images and other assets,
# `/updater`, `/ocs-provider`), and thus
# `try_files $uri $uri/ /index.php$request_uri`
# always provides the desired behaviour.
index index.php index.html /index.php$request_uri;
# Rule borrowed from `.htaccess` to handle Microsoft DAV clients
location = / {
if ( $http_user_agent ~ ^DavClnt ) {
return 302 /remote.php/webdav/$is_args$args;
}
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
# Make a regex exception for `/.well-known` so that clients can still
# access it despite the existence of the regex rule
# `location ~ /(\.|autotest|...)` which would otherwise handle requests
# for `/.well-known`.
location ^~ /.well-known {
# The rules in this block are an adaptation of the rules
# in `.htaccess` that concern `/.well-known`.
location = /.well-known/carddav { return 301 /remote.php/dav/; }
location = /.well-known/caldav { return 301 /remote.php/dav/; }
location /.well-known/acme-challenge { try_files $uri $uri/ =404; }
location /.well-known/pki-validation { try_files $uri $uri/ =404; }
$ sudo -u www-data ls -la /var/www/nextcloud
total 1236
drwxr-xr-x 14 www-data www-data 4096 Mar 12 09:51 .
drwxr-xr-x 4 root root 4096 Mar 12 08:12 ..
drwxr-xr-x 44 www-data www-data 4096 Feb 29 07:49 3rdparty
drwxr-xr-x 50 www-data www-data 4096 Feb 29 07:47 apps
-rw-r--r-- 1 www-data www-data 23796 Feb 29 07:46 AUTHORS
-rw-r--r-- 1 www-data www-data 1906 Feb 29 07:46 composer.json
-rw-r--r-- 1 www-data www-data 3140 Feb 29 07:46 composer.lock
drwxr-xr-x 2 www-data www-data 4096 Mar 12 10:01 config
-rw-r--r-- 1 www-data www-data 4124 Feb 29 07:46 console.php
-rw-r--r-- 1 www-data www-data 34520 Feb 29 07:46 COPYING
drwxr-xr-x 24 www-data www-data 4096 Feb 29 07:49 core
-rw-r--r-- 1 www-data www-data 6317 Feb 29 07:46 cron.php
drwxrwx--- 3 www-data www-data 4096 Mar 12 09:02 data
drwxr-xr-x 2 www-data www-data 16384 Feb 29 07:46 dist
-rw-r--r-- 1 www-data www-data 4123 Mar 12 08:36 .htaccess
-rw-r--r-- 1 www-data www-data 156 Feb 29 07:46 index.html
-rw-r--r-- 1 www-data www-data 4403 Feb 29 07:46 index.php
drwxr-xr-x 6 www-data www-data 4096 Feb 29 07:46 lib
-rw-r--r-- 1 www-data www-data 283 Feb 29 07:46 occ
drwxr-xr-x 2 www-data www-data 4096 Feb 29 07:46 ocs
drwxr-xr-x 2 www-data www-data 4096 Feb 29 07:46 ocs-provider
-rw-r--r-- 1 www-data www-data 7072 Feb 29 07:46 package.json
-rw-r--r-- 1 www-data www-data 1044055 Feb 29 07:46 package-lock.json
-rw-r--r-- 1 www-data www-data 3187 Feb 29 07:46 public.php
-rw-r--r-- 1 www-data www-data 5597 Feb 29 07:46 remote.php
drwxr-xr-x 4 www-data www-data 4096 Feb 29 07:46 resources
-rw-r--r-- 1 www-data www-data 26 Feb 29 07:46 robots.txt
-rw-r--r-- 1 www-data www-data 2452 Feb 29 07:46 status.php
-rw-r--r-- 1 www-data www-data 20 Mar 12 09:51 test.php
drwxr-xr-x 3 www-data www-data 4096 Feb 29 07:46 themes
drwxr-xr-x 2 www-data www-data 4096 Feb 29 07:47 updater
-rw-r--r-- 1 www-data www-data 101 Feb 29 07:46 .user.ini
-rw-r--r-- 1 www-data www-data 403 Feb 29 07:49 version.php