1

Topic: Roundcube as Apache default site (without "/mail")

==== Provide basic information to help troubleshoot ====
- iRedMail version: 0.7.3
- Linux/BSD distribution name and version: CentOS 6
- Any related log? Log is helpful for troubleshooting.
====

Experienced mail admin, but limited experience in Linux/CentOS/Apache.  This is probably less of an iRedMail question than an Apache question, but please bear with me.

I've set up a CentOS machine to do nothing but run iRedMail.  I've gotten everything working just fine so far with two test domains, and sending and receiving of mail is working fine.  Before I roll this out to the rest of my ~1400 users and ~300 domains, I want to make one final change, and I am at a loss as to where to find what I'm looking for. 

Currently, the default setup (which works fine) is to access Roundcube at http://webmail.domain.com/webmail (or http://webmail.domain.com/mail, or http://webmail.domain.com/roundcube).  Since Roundcube is the only "site" running on the machine, I want to reconfigure so that http://webmail.domain.com takes the user directly to the Roundcube login page.  However, I still need http://webmail.domain.com/iredadmin to work as it does now.

I assume there are symlinks set up somewhere for /mail, /webmail, /iredadmin, etc. configured somewhere, but I can't seem to find them.  Any assistance would be appreciated.

----

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

2

Re: Roundcube as Apache default site (without "/mail")

Let me make this simpler.  Currently I'm accessing Roundcube at IPaddress/mail.  I want to be able to access it at IPaddress.  But, I still need to be able to go to IPaddress/iredadmin.  Does that help?

3

Re: Roundcube as Apache default site (without "/mail")

How about this solution: create file /var/www/html/index.html with below content, so that all users access http://IP_Address/ will be redirected to http://IP_Address/mail/ immediately? No addition change required on server.

<html>
    <head>
        <meta HTTP-EQUIV="REFRESH" content="0; url=http://YOUR_IP_ADDRESS/mail/">
    </head>
</html>

4

Re: Roundcube as Apache default site (without "/mail")

The problem with that solution (other than that there should be a way to do this server side) is that there are about 400 different domains involved here, and I want to keep the domain name as part of the URL.  Basically I'm looking for a wildcard solution to redirect any traffic to the Apache root to the mail subdirectory.  In other words, domain.com should automatically redirect to domain.com/mail, regardless of what the domain is. 

I suspect the way to do this is with .htaccess using mod_rewrite, but I'm having a hard time getting it to work.

5 (edited by answerman 2011-10-05 05:29:59)

Re: Roundcube as Apache default site (without "/mail")

Solved it, though not in the manner I wanted to, by creating an index.php page in the webroot and doing a little PHP magic to grab the URL and redirect it to URL/mail.  I suppose it'll work.

Now I just have to figure out why I can't get to any of the other aliases (/iredadmin, /awstats, etc).  I must have mucked something up in the httpd.conf.

***EDIT: never mind, the other aliases are working fine.  I forgot that they require https://***

6

Re: Roundcube as Apache default site (without "/mail")

Glad to hear that.
Would you mind sharing with us how you solved it? Code snippet?

7

Re: Roundcube as Apache default site (without "/mail")

Sure, assuming I can put PHP code here... it's pretty basic, off the top of my head:

Just  a few lines of code, save this in the webroot as  index.php;

<?php
$pageURL = 'http://'.$_SERVER["SERVER_NAME"];
header('Location:'.$pageURL.'/mail');
?>

Now, what happens is that when you go to the webroot, this page is served.  The script graps the domain/IP/whatever address brings you there, stores it in a variable called pageURL, and then redirects to the same URL with "/mail" appended.  Quick, easy, and it doesn't matter what domain you used to get there.

The reason it's important to me: I run a web hosting company and have over 400 domains hosted.  In the DNS for each name, I have a subdomain "webmail" and they all point to the same IP address.  It turns out that redirecting with .htaccess and mod_rewrite doesn't work unless you specify the whole URL in the redirect, and I needed something that didn't involve me having to make 400+ rewrite statements.

Now that I have this figured out, I'm going to start rolling this out to my clients.  So far so good.

8

Re: Roundcube as Apache default site (without "/mail")

answerman wrote:

Sure, assuming I can put PHP code here... it's pretty basic, off the top of my head:

Just  a few lines of code, save this in the webroot as  index.php;

<?php
$pageURL = 'http://'.$_SERVER["SERVER_NAME"];
header('Location:'.$pageURL.'/mail');
?>

Now, what happens is that when you go to the webroot, this page is served.  The script graps the domain/IP/whatever address brings you there, stores it in a variable called pageURL, and then redirects to the same URL with "/mail" appended.  Quick, easy, and it doesn't matter what domain you used to get there.

The reason it's important to me: I run a web hosting company and have over 400 domains hosted.  In the DNS for each name, I have a subdomain "webmail" and they all point to the same IP address.  It turns out that redirecting with .htaccess and mod_rewrite doesn't work unless you specify the whole URL in the redirect, and I needed something that didn't involve me having to make 400+ rewrite statements.

Now that I have this figured out, I'm going to start rolling this out to my clients.  So far so good.


Much simpler, just create a virtual server on your apache with these directives (you can create one on port 80 and another on 443, if you need to keep SSL connectivity):

DocumentRoot /usr/share/apache2/roundcubemail
<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>
<Directory /usr/share/apache2/roundcubemail/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
</Directory>

the path of the DocumentRoot and Directory is for Ubuntu... check in your distro if it's the same.

9

Re: Roundcube as Apache default site (without "/mail")

Hi,

I have a solution from server side I am redirecting my domain like that.
Here is the wild card entry I have used.
Add the below code to your httpd.conf file and restart the apache.

RedirectMatch ^/$ http://example.com/mail

Let me know if it is working or not.

Regards
siddartha.g

10

Re: Roundcube as Apache default site (without "/mail")

Create the site for apache2

cat > /etc/apache2/sites-available/webmail
<VirtualHost *:80>
        ServerAdmin webmaster@your-domain.com
        ServerName webmail.your-domain.com
        DocumentRoot /usr/share/apache2/roundcubemail/
        <Directory /usr/share/apache2/roundcubemail/>
                Options -Indexes
        </Directory>

        ErrorLog /var/log/apache2/webmail-error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog /var/log/apache2/webmail-access.log combined


</VirtualHost>

Enable the site.
a2ensite webmail

Restart Apache2
/etc/init.d/apache2 reload