Not Found The requested URL / was not found on this server

Hi im trying to enter in nextcloud using nginx 1.14 and ubuntu 18.04 i get this error:

I try to access to “my nextcloud address”:

Not Found

The requested URL / was not found on this server.

My etc/hosts:

    127.0.0.1 localhost
    127.0.0.1 "my nextcloud address"

My default /etc/nginx/conf.d/default.conf :

    server {
      listen 80;
      listen [::]:80;
      server_name _;
      root /usr/share/nginx/html/;
      index index.php index.html index.htm index.nginx-debian.html;

      location / {
        try_files $uri $uri/ /index.php;
      }

      location ~ \.php$ {
        fastcgi_pass unix:/run/php/php7.2-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        include snippets/fastcgi-php.conf;
      }


     # A long browser cache lifetime can speed up repeat visits to your page
      location ~* \.(jpg|jpeg|gif|png|webp|svg|woff|woff2|ttf|css|js|ico|xml)$ {
           access_log        off;
           log_not_found     off;
           expires           360d;
      }

      # disable access to hidden files
      location ~ /\.ht {
          access_log off;
          log_not_found off;
          deny all;
      }
    }

My /etc/nginx/sites-available default :
##
# You should look at the following URL’s in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# https://www.nginx.com/resources/wiki/start/
# https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
# https://wiki.debian.org/Nginx/DirectoryStructure
#
# In most cases, administrators will remove this file from sites-enabled/ and
# leave it as reference inside of sites-available where it will continue to be
# updated by the nginx packaging team.
#
# This file will automatically load configuration files provided by other
# applications, such as Drupal or Wordpress. These applications will be made
# available underneath a path with that package name, such as /drupal8.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##

    # Default server configuration
    #
    server {
    	listen 80 default_server;
    	listen [::]:80 default_server;

    	# SSL configuration
    	#
    	# listen 443 ssl default_server;
    	# listen [::]:443 ssl default_server;
    	#
    	# Note: You should disable gzip for SSL traffic.
    	# See: https://bugs.debian.org/773332
    	#
    	# Read up on ssl_ciphers to ensure a secure configuration.
    	# See: https://bugs.debian.org/765782
    	#
    	# Self signed certs generated by the ssl-cert package
    	# Don't use them in a production server!
    	#
    	# include snippets/snakeoil.conf;

    	root /var/www/html;

    	# Add index.php to the list if you are using PHP
    	index index.html index.htm index.nginx-debian.html;

    	server_name _;

    	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:/var/run/php/php7.0-fpm.sock;
    	#	# With php-cgi (or other tcp sockets):
    	#	fastcgi_pass 127.0.0.1:9000;
    	#}

    	# deny access to .htaccess files, if Apache's document root
    	# concurs with nginx's one
    	#
    	#location ~ /\.ht {
    	    #	deny all;
            	#}
            }


            # Virtual Host configuration for example.com
            #
            # You can move that to a different file under sites-available/ and symlink that
            # to sites-enabled/ to enable it.
            #
            #server {
            #	listen 80;
            #	listen [::]:80;
            #
            #	server_name example.com;
            #
            #	root /var/www/example.com;
            #	index index.html;
            #
            #	location / {
            #		try_files $uri $uri/ =404;
            #	}
            #}

My /etc/nginx/sites-available/nextcloud :
server {
listen 80;
server_name nextcloud.laia.com;

        # Add headers to serve security related headers
        add_header X-Content-Type-Options nosniff;
        add_header X-XSS-Protection "1; mode=block";
        add_header X-Robots-Tag none;
        add_header X-Download-Options noopen;
        add_header X-Permitted-Cross-Domain-Policies none;
        add_header Referrer-Policy no-referrer;

        #I found this header is needed on Ubuntu, but not on Arch Linux. 
        add_header X-Frame-Options "SAMEORIGIN";

        # Path to the root of your installation
        root /var/www/nextcloud/;

        access_log /var/log/nginx/nextcloud.access;
        error_log /var/log/nginx/nextcloud.error;

        location = /robots.txt {
            allow all;
            log_not_found off;
            access_log off;
        }

        # The following 2 rules are only needed for the user_webfinger app.
        # Uncomment it if you're planning to use this app.
        #rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
        #rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json
        # last;

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

        location ~ /.well-known/acme-challenge {
          allow all;
        }

        # set max upload size
        client_max_body_size 512M;
        fastcgi_buffers 64 4K;

        # Disable gzip to avoid the removal of the ETag header
        gzip off;

        # Uncomment if your server is build with the ngx_pagespeed module
        # This module is currently not supported.
        #pagespeed off;

        error_page 403 /core/templates/403.php;
        error_page 404 /core/templates/404.php;

        location / {
           rewrite ^ /index.php$uri;
        }

        location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)/ {
           deny all;
        }
        location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) {
           deny all;
         }

        location ~ ^/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+|core/templates/40[34])\.php(?:$|/) {
           include fastcgi_params;
           fastcgi_split_path_info ^(.+\.php)(/.*)$;
           fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
           fastcgi_param PATH_INFO $fastcgi_path_info;
           #Avoid sending the security headers twice
           fastcgi_param modHeadersAvailable true;
           fastcgi_param front_controller_active true;
           fastcgi_pass unix:/run/php/php7.2-fpm.sock;
           fastcgi_intercept_errors on;
           fastcgi_request_buffering off;
        }

        location ~ ^/(?:updater|ocs-provider)(?:$|/) {
           try_files $uri/ =404;
           index index.php;
        }

        # Adding the cache control header for js and css files
        # Make sure it is BELOW the PHP block
        location ~* \.(?:css|js)$ {
            try_files $uri /index.php$uri$is_args$args;
            add_header Cache-Control "public, max-age=7200";
            # Add headers to serve security related headers (It is intended to
            # have those duplicated to the ones above)
            add_header X-Content-Type-Options nosniff;
            add_header X-XSS-Protection "1; mode=block";
            add_header X-Robots-Tag none;
            add_header X-Download-Options noopen;
            add_header X-Permitted-Cross-Domain-Policies none;
            add_header Referrer-Policy no-referrer;
            # Optional: Don't log access to assets
            access_log off;
       }

       location ~* \.(?:svg|gif|png|html|ttf|woff|ico|jpg|jpeg)$ {
            try_files $uri /index.php$uri$is_args$args;
            # Optional: Don't log access to other assets
            access_log off;
       }
    }

I have also the symbolic links inside sites-enabled pointing to them…

I have my nextcloud installation at /var/www/nextcloud…

I dont know what im doing wrong

Any help would be apreciated

Thanks in advance

1 Like

Please post the output of
curl -I https://your.domain

plus the related content of the webserver logfile.

I have deleted /etc/nginx/conf.d/default.conf

My localhost:

# Default server configuration
#
server {
	listen 80 default_server;
	listen [::]:80 default_server;


	root /var/www/html;

	# Add index.php to the list if you are using PHP
	index index.html index.htm index.nginx-debian.html;

	server_name _;

	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:/var/run/php/php7.2-fpm.sock;
		# With php-cgi (or other tcp sockets):
	#	fastcgi_pass 127.0.0.1:9000;
	}

	# deny access to .htaccess files, if Apache's document root
	# concurs with nginx's one
	#
	#location ~ /\.ht {
	#	deny all;
	#}
}

My /etc/nginx/sites-avalaible/nextcloud :

server {
    listen 80;
    server_name nextcloud.laia.com;

    # Add headers to serve security related headers
    add_header X-Content-Type-Options nosniff;
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Robots-Tag none;
    add_header X-Download-Options noopen;
    add_header X-Permitted-Cross-Domain-Policies none;
    add_header Referrer-Policy no-referrer;

    #I found this header is needed on Ubuntu, but not on Arch Linux. 
    add_header X-Frame-Options "SAMEORIGIN";

    # Path to the root of your installation
    root /var/www/nextcloud/;

    access_log /var/log/nginx/nextcloud.access;
    error_log /var/log/nginx/nextcloud.error;

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    # The following 2 rules are only needed for the user_webfinger app.
    # Uncomment it if you're planning to use this app.
    #rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
    #rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json
    # last;

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

    location ~ /.well-known/acme-challenge {
      allow all;
    }

    # set max upload size
    client_max_body_size 512M;
    fastcgi_buffers 64 4K;

    # Disable gzip to avoid the removal of the ETag header
    gzip off;

    # Uncomment if your server is build with the ngx_pagespeed module
    # This module is currently not supported.
    #pagespeed off;

    error_page 403 /core/templates/403.php;
    error_page 404 /core/templates/404.php;

    location / {
       rewrite ^ /index.php$uri;
    }

    location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)/ {
       deny all;
    }
    location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) {
       deny all;
     }

    location ~ ^/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+|core/templates/40[34])\.php(?:$|/) {
       include fastcgi_params;
       fastcgi_split_path_info ^(.+\.php)(/.*)$;
       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
       fastcgi_param PATH_INFO $fastcgi_path_info;
       #Avoid sending the security headers twice
       fastcgi_param modHeadersAvailable true;
       fastcgi_param front_controller_active true;
       fastcgi_pass unix:/run/php/php7.2-fpm.sock;
       fastcgi_intercept_errors on;
       fastcgi_request_buffering off;
    }

    location ~ ^/(?:updater|ocs-provider)(?:$|/) {
       try_files $uri/ =404;
       index index.php;
    }

    # Adding the cache control header for js and css files
    # Make sure it is BELOW the PHP block
    location ~* \.(?:css|js)$ {
        try_files $uri /index.php$uri$is_args$args;
        add_header Cache-Control "public, max-age=7200";
        # Add headers to serve security related headers (It is intended to
        # have those duplicated to the ones above)
        add_header X-Content-Type-Options nosniff;
        add_header X-XSS-Protection "1; mode=block";
        add_header X-Robots-Tag none;
        add_header X-Download-Options noopen;
        add_header X-Permitted-Cross-Domain-Policies none;
        add_header Referrer-Policy no-referrer;
        # Optional: Don't log access to assets
        access_log off;
   }

   location ~* \.(?:svg|gif|png|html|ttf|woff|ico|jpg|jpeg)$ {
        try_files $uri /index.php$uri$is_args$args;
        # Optional: Don't log access to other assets
        access_log off;
   }
}

My /etc/hosts:

laiajun@laiajun-VirtualBox:~$ sudo cat /etc/hosts

127.0.0.1	localhost
127.0.0.1	nextcloud.laia.com
127.0.1.1	laiajun-VirtualBox

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

curl -l:

laiajun@laiajun-VirtualBox:/etc/nginx/sites-enabled$ curl -I http://nextcloud.laia.com
HTTP/1.1 404 Not Found
Content-Type: text/html; charset=iso-8859-1
X-Cacheable: YES:Forced
Date: Fri, 13 Dec 2019 11:34:50 GMT
Age: 0
Vary: User-Agent
X-Cache: uncached
X-Cache-Hit: MISS
X-Backend: all_requests
X-Cache: MISS from localhost
X-Cache-Lookup: MISS from localhost:3128
Via: 1.1 localhost (squid)
Connection: keep-alive

laiajun@laiajun-VirtualBox:/etc/nginx/sites-enabled$ cat /var/log/nginx/access.log
127.0.0.1 - - [13/Dec/2019:12:05:21 +0100] "GET /prova.php HTTP/1.1" 404 152 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:71.0) Gecko/20100101 Firefox/71.0"
127.0.0.1 - - [13/Dec/2019:12:06:11 +0100] "GET /prova.php HTTP/1.1" 200 35551 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:71.0) Gecko/20100101 Firefox/71.0"
127.0.0.1 - - [13/Dec/2019:12:25:00 +0100] "GET / HTTP/1.1" 200 406 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:71.0) Gecko/20100101 Firefox/71.0"
127.0.0.1 - - [13/Dec/2019:12:25:06 +0100] "GET /prova.php HTTP/1.1" 200 197 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:71.0) Gecko/20100101 Firefox/71.0"
127.0.0.1 - - [13/Dec/2019:12:31:31 +0100] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:71.0) Gecko/20100101 Firefox/71.0"
127.0.0.1 - - [13/Dec/2019:12:31:31 +0100] "GET /favicon.ico HTTP/1.1" 404 152 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:71.0) Gecko/20100101 Firefox/71.0"
127.0.0.1 - - [13/Dec/2019:12:31:49 +0100] "GET /prova.php HTTP/1.1" 200 35640 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:71.0) Gecko/20100101 Firefox/71.0"
laiajun@laiajun-VirtualBox:/etc/nginx/sites-enabled$ cat /var/log/nginx/error.log
2019/12/13 12:30:13 [emerg] 8956#8956: "fastcgi_pass" directive is duplicate in /etc/nginx/sites-enabled/default:30
2019/12/13 12:30:25 [emerg] 8958#8958: "fastcgi_pass" directive is duplicate in /etc/nginx/sites-enabled/default:30

Your curl request is not showing up in that log. Could you keep squid out until you solved this problem?

1 Like

I have the same problem as @Jun_Lopez , can you explain better please, english is not my mother language… You mean i have to make curl again… ??

As you can see we dont use ssl

Hi there,

I have got the same problem, this is the curl output. Could you please check it.

HTTP/1.1 404 Not Found
Date: Sun, 26 Apr 2020 17:26:11 GMT
Server: Apache
Referrer-Policy: no-referrer
X-Content-Type-Options: nosniff
X-Download-Options: noopen
X-Frame-Options: SAMEORIGIN
X-Permitted-Cross-Domain-Policies: none
X-Robots-Tag: none
X-XSS-Protection: 1; mode=block
Content-Type: text/html; charset=iso-8859-1

strong text

1 Like

Hi, same problem here. I have installed NextCloud on top of OMV5. I am able to access OMV5 on port 90 but not able to access NextCloud, not even on port 4443.

Any suggestion?