1

Topic: NextCloud Error 404 - /index.php/apps/files/

================ Required information ====
- iRedMail version (check /etc/iredmail-release): 0.9.7 MARIADB edition
- Linux/BSD distribution name and version: CentOS Linux release 7.4.1708 (Core)
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): MySQL
- Web server (Apache or Nginx): Nginx
- Manage mail accounts with iRedAdmin-Pro? No
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
========================================

Hi to all,

first of all thanks for your work for iRedMail and for your support.
I'm quite new with Nginx but as that default version for next upgrade i choose to use it on my personal server.
After configure mail to 'webmail.magri.email', i've try to install nextcloud on the same server.
To solve the problem with the php version, I did an upgrade following the steps below :

yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum-config-manager --enable remi-php56
yum update

After that i've just download nextcloud in the directory '/var/www/nextcloud/', change the owner to nginx, group nginx, files permission to 0755 and try to install with the following configuration as vhost :

server {
        listen 80;
        listen [::]:80;
        server_name nextcloud.magri.email;
        return 301 https://$server_name$request_uri;
}
server {
        listen 443;
        listen [::]:443;
        include /etc/nginx/templates/hsts.tmpl;
        root /var/www/nextcloud;
        index index.php index.html;
        server_name nextcloud.magri.email;
        ssl on;
        ssl_dhparam /etc/nginx/ssl/dhparam.pem;
        ssl_certificate /etc/letsencrypt/live/nextcloud.magri.email/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/nextcloud.magri.email/privkey.pem;
        ssl_protocols TLSv1.2;
        ssl_ciphers "DHE-RSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-GCM-SHA384 !RC4 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS";
        ssl_prefer_server_ciphers on;
        ssl_session_cache shared:SSL:10m;

        location ~ \.php$ {
                        include /etc/nginx/templates/fastcgi_php.tmpl;
                        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                        }

        location ~ ^/(bin|SQL|README|INSTALL|LICENSE|CHANGELOG|UPGRADING)$ { deny all; }
        }

It appear fine, but after installation a page with error 404 was report back to me and the adress change to 'https://nextcloud.magri.email/index.php/apps/files/'.

I've try to manage how to solve it without solve the issue.
Can someone tell me where i wrong ?

Thanks again.

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: NextCloud Error 404 - /index.php/apps/files/

Does adding a "localtion / {}" block inside the https server part work for you? for example:

server {
    listen 443;
    ...
    location / {
        root /var/www/nextcloud;
    }
    ...
}

3 (edited by LainX84 2017-10-26 14:20:07)

Re: NextCloud Error 404 - /index.php/apps/files/

ZhangHuangbin wrote:

Does adding a "localtion / {}" block inside the https server part work for you? for example:

server {
    listen 443;
    ...
    location / {
        root /var/www/nextcloud;
    }
    ...
}

I've try to put it in my conf file but same result sad
In addition, if I try to link directly to the index. html or index. php file, the browser proposes to download it.

4

Re: NextCloud Error 404 - /index.php/apps/files/

Try:

location ~ ^/(.*) {
    alias /var/www/nextcloud/$1;
}

5 (edited by LainX84 2017-10-26 21:05:49)

Re: NextCloud Error 404 - /index.php/apps/files/

With that modify it require me open that file : application/octet-stream (2,7 kB)
Result is php page :

<?php
/**
 * @copyright Copyright (c) 2016, ownCloud, Inc.
 *
 * @author Jörn Friedrich Dreyer <jfd@butonic.de>
 * @author Lukas Reschke <lukas@statuscode.ch>
 * @author Morris Jobke <hey@morrisjobke.de>
 * @author Robin Appelman <robin@icewind.nl>
 * @author Thomas Müller <thomas.mueller@tmit.eu>
 * @author Vincent Petry <pvince81@owncloud.com>
 *
 * @license AGPL-3.0
 *
 * This code is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License, version 3,
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License, version 3,
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 *
 */

// Show warning if a PHP version below 5.6.0 is used, this has to happen here
// because base.php will already use 5.6 syntax.
if (version_compare(PHP_VERSION, '5.6.0') === -1) {
    echo 'This version of Nextcloud requires at least PHP 5.6.0<br/>';
    echo 'You are currently running ' . PHP_VERSION . '. Please update your PHP version.';
    return;
}

// Show warning if PHP 7.2 is used as Nextcloud is not compatible with PHP 7.2 for now
// @see https://github.com/nextcloud/server/pull/5791
if (version_compare(PHP_VERSION, '7.2.0') !== -1) {
    echo 'This version of Nextcloud is not compatible with PHP 7.2.<br/>';
    echo 'You are currently running ' . PHP_VERSION . '.';
    return;
}

try {

    require_once __DIR__ . '/lib/base.php';

    OC::handleRequest();

} catch(\OC\ServiceUnavailableException $ex) {
    \OC::$server->getLogger()->logException($ex, array('app' => 'index'));

    //show the user a detailed error page
    OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE);
    OC_Template::printExceptionErrorPage($ex);
} catch (\OC\HintException $ex) {
    OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE);
    OC_Template::printErrorPage($ex->getMessage(), $ex->getHint());
} catch (\OC\User\LoginException $ex) {
    OC_Response::setStatus(OC_Response::STATUS_FORBIDDEN);
    OC_Template::printErrorPage($ex->getMessage(), $ex->getMessage());
} catch (Exception $ex) {
    \OC::$server->getLogger()->logException($ex, array('app' => 'index'));

    //show the user a detailed error page
    OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR);
    OC_Template::printExceptionErrorPage($ex);
} catch (Error $ex) {
    \OC::$server->getLogger()->logException($ex, array('app' => 'index'));
    OC_Response::setStatus(OC_Response::STATUS_INTERNAL_SERVER_ERROR);
    OC_Template::printExceptionErrorPage($ex);
}

6

Re: NextCloud Error 404 - /index.php/apps/files/

Check NextCloud official doc:
https://docs.nextcloud.com/server/11/ad … ud_9x.html

7

Re: NextCloud Error 404 - /index.php/apps/files/

ZhangHuangbin wrote:

Check NextCloud official doc:
https://docs.nextcloud.com/server/11/ad … ud_9x.html

Do it :

upstream php-handler {
    server 127.0.0.1:9000;
    #server unix:/var/run/php5-fpm.sock;
}

server {
    listen 80;
    server_name nextcloud.magri.email;
    # enforce https
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl;
    server_name nextcloud.magri.email;
    ssl_dhparam /etc/nginx/ssl/dhparam.pem;
    ssl_certificate /etc/letsencrypt/live/nextcloud.sempai.it/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/nextcloud.sempai.it/privkey.pem;

    # Add headers to serve security related headers
    # Before enabling Strict-Transport-Security headers please read into this
    # topic first.
    #add_header Strict-Transport-Security "max-age=15768000;
    # includeSubDomains; preload;";
    add_header X-Content-Type-Options nosniff;
    add_header X-Frame-Options "SAMEORIGIN";
    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;

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

    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 /nextcloud/public.php?service=host-meta
    # last;
    #rewrite ^/.well-known/host-meta.json
    # /nextcloud/public.php?service=host-meta-json last;

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

    location /.well-known/acme-challenge { }

    location ^~ /nextcloud {

        # 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;

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

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

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

        location ~ ^/nextcloud/(?: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|woff|svg|gif)$ {
            try_files $uri /nextcloud/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)
            # Before enabling Strict-Transport-Security headers please read
            # into this topic first.
            # add_header Strict-Transport-Security "max-age=15768000;
            # includeSubDomains; preload;";
            add_header X-Content-Type-Options nosniff;
            add_header X-Frame-Options "SAMEORIGIN";
            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;
            # Optional: Don't log access to assets
            access_log off;
        }

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

but as before, it let me download the index.php.
I think it do not use the php-fpm module.

8

Re: NextCloud Error 404 - /index.php/apps/files/

LainX84 wrote:

upstream php-handler {
    server 127.0.0.1:9000;
    #server unix:/var/run/php5-fpm.sock;
}

You can remove this line since you don't have php-fpm.

9

Re: NextCloud Error 404 - /index.php/apps/files/

ZhangHuangbin wrote:
LainX84 wrote:

upstream php-handler {
    server 127.0.0.1:9000;
    #server unix:/var/run/php5-fpm.sock;
}

You can remove this line since you don't have php-fpm.

Oct 26 14:03:53 srv-main.magri.email systemd[1]: Starting The nginx HTTP and reverse proxy server...
Oct 26 14:03:53 srv-main.magri.email nginx[19765]: nginx: [emerg] no port in upstream "php-handler" in /etc/nginx/sites-enabled/nextcloud.magri.email.conf:90
Oct 26 14:03:53 srv-main.magri.email nginx[19765]: nginx: configuration file /etc/nginx/nginx.conf test failed
Oct 26 14:03:54 srv-main.magri.email systemd[1]: nginx.service: control process exited, code=exited status=1
Oct 26 14:03:54 srv-main.magri.email systemd[1]: Failed to start The nginx HTTP and reverse proxy server.
Oct 26 14:03:54 srv-main.magri.email systemd[1]: Unit nginx.service entered failed state.
Oct 26 14:03:54 srv-main.magri.email systemd[1]: nginx.service failed.

10

Re: NextCloud Error 404 - /index.php/apps/files/

iRedMail has upstream 'php_workers' for php-fpm (defined in /etc/nginx/conf-available/php-fpm.conf), you can use it directly.