1 (edited by crewcutbm 2020-03-14 04:22:48)

Topic: web connects always routed to roundube mail login page

==== REQUIRED BASIC INFO OF YOUR IREDMAIL SERVER ====
- iRedMail version (check /etc/iredmail-release):
- Deployed with iRedMail Easy or the downloadable installer?
- Linux/BSD distribution name and version:
- Store mail accounts in which backend (LDAP/MySQL/PGSQL):
- Web server (Apache or Nginx):
- Manage mail accounts with iRedAdmin-Pro?
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
====
Clean install of iredmail 9.9 on ubuntu 18.04 (by downloadable installer)
mail stored in MySQL
Webserver is Nginx
I have created additional server blocks (for virtual hosts) on the same machine for other domains (not related to email server at all.
in /etc/nginx/sites-available/
-rw-r--r--  1 root root  271 Mar 13 21:41 00-default.conf
-rw-r--r--  1 root root  597 Mar 13 08:47 00-default-ssl.conf
-rw-r--r--  1 root root  441 Mar 13 21:50 domain1.com.conf

created symbolic ink in /etc/nginx/sites-enabled/
lrwxrwxrwx  1 root root   42 Mar 13 08:47 00-default.conf -> /etc/nginx/sites-available/00-default.conf
lrwxrwxrwx  1 root root   46 Mar 13 08:47 00-default-ssl.conf -> /etc/nginx/sites-available/00-default-ssl.conf
lrwxrwxrwx  1 root root   45 Mar 13 20:46 domain1.com.conf -> /etc/nginx/sites-available/domain1.com.conf

content of domain1.com.conf

# Note: This file must be loaded before other virtual host config files,
#
# HTTP
server {
    # Listen on ipv4
    listen 80;
    listen [::]:80;
        index index.html index.htm;
        location / {
                try_files $uri $uri/ =404;
        }
    server_name domain1.com www.domain1.com;
    root /opt/www/domain1.com/public_html;
    # Redirect all insecure http:// requests to https://
    return 301 https://$host$request_uri;


I have tried putting the index file in the following locations:
/opt/www/domain1.com/index.html
/etc/www/html/domain1.com/index.html

PROBLEM = attempts to connect to this domain are always routed to the roundcube login page located at:
/opt/www/roundcubemail/public_html/index.php

Can someone see where I have gone wrong?

----

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

2

Re: web connects always routed to roundube mail login page

- The "return 301 ..." line redirects http traffic to https, but you didn't show us your https server block for this domain. i guess you forgot to add it?
- Try to move "root /opt/www/..." line above "index index.html ..." line.

3 (edited by crewcutbm 2020-03-14 12:53:42)

Re: web connects always routed to roundube mail login page

ZhangHuangbin wrote:

- The "return 301 ..." line redirects http traffic to https, but you didn't show us your https server block for this domain. i guess you forgot to add it?
- Try to move "root /opt/www/..." line above "index index.html ..." line.

Thanks for the reply.
I changed my server block to the below, but still redirects to the roundcube mail folder.
I remarked out the https redirect just for testing, I want to have a separate le cert for the website later (there is no server block for https on this site yet), not sure if this was the right way to deal with that issue.



#
# Note: This file must be loaded before other virtual host config files,
#
# HTTP
server {
    # Listen on ipv4
    listen 80;
    listen [::]:80;
    root /opt/www/domain1.com/public_html;
        index index.html index.htm;
        location / {
                try_files $uri $uri/ =404;
        }
    server_name domain1.com www.domain1.com;
    # Redirect all insecure http:// requests to https://
    #return 301 https://$host$request_uri;
}

4

Re: web connects always routed to roundube mail login page

Your web host config file seems fine. Try to access it with http://, not https://.

5

Re: web connects always routed to roundube mail login page

ZhangHuangbin wrote:

Your web host config file seems fine. Try to access it with http://, not https://.

Thanks, that was the test I conducted.
It still redirects to domain1.com/mail (which is the roundcube login prompt).
I looked in the iredmail documentation and it says something about using custom settings but when I try to find the folders mentioned they are not in the file structure.

6

Re: web connects always routed to roundube mail login page

When checking out iRedMail i imagined the same scenario as you presented here is my approach :

In /etc/nginx/sites-available i have created 2 folders : domain1.tld , domain2.tld
In each folder there are two conf files (ssl and non ssl), tree output  and files content below

 
/etc/nginx/sites-available# tree
.
├── 00-default-ssl.conf
├── 00-default.conf
├── domain1.tld
│   ├── domain1-tld-ssl.conf
│   └── domain1-tld.conf
└── domain2.tld
    ├── domain2-tld-ssl.conf
    └── domain2-tld.conf


cat domain1-tld.conf 

#
# Note: This file must be loaded before other virtual host config files,
#
# HTTP
server {
    if ($host = domain1.tld) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    if ($host = www.domain1.tld) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    # Listen on ipv4
    listen 80;
    listen [::]:80;

    server_name domain1.tld www.domain1.tld;

    # Redirect all insecure http:// requests to https://
    return 301 https://$host$request_uri;
}



cat domain1-tld-ssl.conf 

#
# Note: This file must be loaded before other virtual host config files,
#
# HTTPS
server {
    listen 443 ssl;
    listen [::]:443 ssl;
    server_name domain1.tld  www.domain1.tld;

    root /var/www/html;
    index index.php index.html;

    include /etc/nginx/templates/misc.tmpl;
    include /etc/nginx/templates/ssl.tmpl;
    include /etc/nginx/templates/iredadmin.tmpl;
    include /etc/nginx/templates/roundcube.tmpl;
    include /etc/nginx/templates/sogo.tmpl;
    include /etc/nginx/templates/netdata.tmpl;
    include /etc/nginx/templates/php-catchall.tmpl;
    include /etc/nginx/templates/stub_status.tmpl;
    ssl_certificate /etc/letsencrypt/live/domain1.tld /fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/domain1.tld /privkey.pem; # managed by Certbot
}

domain2.tld files are similar (different certs and root path)
After that I have removed default config from sites-enabled and linked the ones i made.

/etc/nginx/sites-enabled# tree
.
├── domain1-tld-ssl.conf -> /etc/nginx/sites-available/domain1.tld/domain1-tld-ssl.conf
├── domain1-tld.conf -> /etc/nginx/sites-available/domain1-tld/domain1-tld.conf
├── domain2-tld-ssl.conf -> /etc/nginx/sites-available/domain2.tld/domain2-tld-ssl.conf
└── domain2-tld.conf -> /etc/nginx/sites-available/domain2.tld/domain2-tld.conf

Original, manual created files, were a little different but certbot modified them and if it works why bother big_smile


Hope this helps.

P.S. by keeping the inserts in both files I can access the same email from each domain big_smile -- it's not an oversight just desired comportment (a feature not a bug  smile )

7

Re: web connects always routed to roundube mail login page

crewcutbm wrote:

It still redirects to domain1.com/mail (which is the roundcube login prompt).

Please turn on debug mode in Nginx to figure out why it redirects to https://domain1.com/mail.
FYI: http://docs.iredmail.org/debug.nginx.html