Topic: iRedMail Nextcloud 16

- iRedMail version (check /etc/iredmail-release): 0.99
- Deployed with iRedMail Easy or the downloadable installer? downloadable installer
- Linux/BSD distribution name and version: Ubuntu 18.04.02
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): LDAP
- 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.

Hey there,
I think I'm going a bit nuts. lol I've been trying many different NGINX configuration files to get Nextcloud working on the same server as iRedmail, but under a different sub-domain. What ever I try nothing seems to work, although the most basic config does work but doesn't add a lot to securing NC.

My current NC NGINX config is:

server {
    listen 80;
    listen [::]:80;
    root /opt/www/nextcloud;
    index  index.php index.html index.htm;
    server_name nextcloud.server.domain;

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

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

    location ~ ^/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+|core/templates/40[34])\.php(?:$|/) {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        fastcgi_intercept_errors on;
        fastcgi_request_buffering off;

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

    location ~* \.(?:svg|gif|png|html|ttf|woff|ico|jpg|jpeg)$ {
        try_files $uri /index.php$uri$is_args$args;
        access_log off;


This document is saved in /etc/nginx/sites-enabled as nextcloud.conf

The problem with this particular configuration is that whenever I type in the URL http://nextcloud.server.domain/ I'm redirected to https://nextcloud.server.domain/mail/.

I'm not able to spot the issue here, I hope someone else sees it and can point me in the right direction.
Any help would be much appreciated.


2 (edited by davidzamoraruiz1988 2019-05-13 08:42:39)

Re: iRedMail Nextcloud 16

It is best to separate each app on a different server.  And safer.  If there is any error you detect quickly where it comes from.  Sorry, I'm not in favor of using everything on the same server.  Cheers.


Re: iRedMail Nextcloud 16

Yeah I get that, and that is what I would do where this a professional install. However it's just for my home setup where I have to take the cost in to consideration.
Thanks anyway.


Re: iRedMail Nextcloud 16

For the past 4 hours I've been trying and trying getting a step closer each time. For some reason though I was getting a Bad Gateway error each time after NC installed.
While writing a post on the NC forum and trying out one last time to remove manually recreate the NC database it somehow started working.
So, while I'm not sure what I did, everything seems to work now.