PDA

View Full Version : how to redirect mail.anydomain to the webmail vhost


Ovidiu
5th May 2009, 22:27
I had this working in ispcfg2 but can't get it to work with ispcfg3.

basically I tried inserting this into /etc/apache2/apache.conf

<VirtualHost 85.214.146.68:80>
ServerName webmail
ServerAlias mail.*
ErrorLog /var/www/webmail/log/error.log
ServerAdmin postmaster@web-designerz.de
DocumentRoot /var/www/webmail
DirectoryIndex index.html index.htm index.php index.php5 index.php4 index.php3 $
AddType application/x-httpd-php .php .php3 .php4 .php5
</VirtualHost>#

# Include the virtual host configurations:
Include /etc/apache2/sites-enabled/


tried both including it before Include /etc/apache2/sites-enabled/ and after that statement but b0oth times it just goes wrong and redirects all sites/vhosts to the squirrelmail interface :-(

can someone point out what I am doing wrong here?

falko
6th May 2009, 23:05
Can you replace
</VirtualHost>#

with
</VirtualHost>?

Ovidiu
7th May 2009, 13:48
silly mistake, but it didn't change a thing, all vhosts get redirected to the webmail login :-(

anything else I might be doing wrong?

falko
8th May 2009, 01:08
Does this happen only if you use the webmail subdomain, or also for the mail subdomain?

Ovidiu
8th May 2009, 08:36
I tried
<VirtualHost 85.214.146.68:80>
ServerName mail
ServerAlias mail.*
ErrorLog /var/www/webmail/log/error.log
ServerAdmin postmaster@web-designerz.de
DocumentRoot /var/www/webmail
DirectoryIndex index.html index.htm index.php index.php5 index.php4 index.php3 $
AddType application/x-httpd-php .php .php3 .php4 .php5
</VirtualHost>


same result...

this is weird. here is the exact vhost settigns I was using in ispcfg3 and it worked and still works perfectly:
<VirtualHost 85.214.51.208:443>
ServerName webmail
ServerAlias mail.*
ScriptAlias /cgi-bin/ /var/www/webmail/cgi-bin/
AddHandler cgi-script .cgi
AddHandler cgi-script .pl
ErrorLog /var/www/webmail/log/error.log
ServerAdmin postmaster@web-designerz.de
DocumentRoot /var/www/webmail/web
DirectoryIndex index.html index.htm index.php index.php5 index.php4 index.php3 $
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/server.crt
SSLCertificateKeyFile /etc/apache2/ssl/server.key
SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0
AddType application/x-httpd-php .php .php3 .php4 .php5
</VirtualHost>

<VirtualHost 85.214.51.208:80>
ServerName webmail
ServerAlias mail.*
RewriteEngine On
RewriteRule (.*) https://%{SERVER_NAME}:443 [R]
</VirtualHost>


the only difference is that there I was using port 443 but I can't find a good howto generate those security certificates anymore, so I thought I'd settle for port 80

falko
9th May 2009, 13:32
No, I meant, does this happen only if you use the webmail subdomain, or also for the mail subdomain in the browser?

Ovidiu
9th May 2009, 14:22
I am really not getting it !?

if I try opening in my browser any domain hsoted on my sever, they all lead to the squirrelmail login.

if I try mail.anydomain on my server they also lead there?

does this answer your question? am unsure how to understand your question :-)

falko
10th May 2009, 17:57
Hm, that's really strange. I have no idea why this is happening.

tio289
15th May 2009, 11:18
you can try use only rewrite rules in all vhosts

fastgrav
10th June 2009, 10:12
Hi,

add the following lines in /etc/apache2/conf.d/apache2-doc

Alias /webmail /usr/share/squirrelmail/

<Directory "/usr/share/squirrelmail/">
Options Indexes FollowSymlinks
AllowOverride None
Order allow,deny
Allow from all
AddDefaultCharset off
</Directory>

and every virtual domain will have a www.virt-domain.com/webmail

Andrei

Ovidiu
11th June 2009, 23:25
thx, that actually helped, now if you could help me out getting mail.* to work for all domains, so that basically mail.whateverdomain.com wil lead to my squirrelmail installation, that woudl be great :-)

Amorphous
19th June 2009, 20:58
same problem here, installed ispconfig 3, everything was fine, 2 days, and from that on, problems like not making anymore mail accounts, using only 3- 4 mail accounts max, or it s making me only on one of the test sites, but for the tothers not making, exactlly now i m trying to reinstall ispconfig 3 on a centos 5.2 server, i hope will not get same problems ...
one other thing ... i have a domain of my own, domain.com let s say , i am trying to make mail accounts for that domain, but no chance.. isconfig created the mail account, let s say admin@domain.com , but is not receiving anything, i can send e-mails, but no receive .... the eror i m getting in the mail that i m sending from is a replay from mailer-daemon that the account doesn t exists.

one other problem is with fresh new e-mail accounts, each one of them is not registered in var/vmail/domain and trying to connect in that account newlly created i get "connection dropped by IMAP server "

any ideeas ???

i m telling again, i m reinstalling ispconfig 3 on a centos 5.3 the problems that i had were on a fedora 10 server

till
30th June 2009, 09:30
@Amorphus: This is all not related to this thread. If you have any problems with creating email accounts, please make a new thread.

Amorphous
25th August 2009, 22:10
hope this helps , i just found out myself


go to /etc/httpd/conf/sites-enabled/mail.domain.comvhost

assuming u allready created a website mail.domain.com, there u will find the virtualhost settings:

the settings initially look like this

<Directory /var/www/mail.domain.com> ( change this to /usr/share/squirrelmail )
AllowOverride None
Order Deny,Allow
Deny from all
</Directory>

<VirtualHost *:80>
DocumentRoot /var/www/mail.domain.com/web ( change this to /usr/share/squirrelmail )

ServerName mail.domain.com
ServerAdmin webmaster@mail.domain.com ( change this with your real e-mail address , eg.: master@domain.com )

ErrorLog /var/log/ispconfig/httpd/mail.domain.com/error.log (u can leave the error logs in the same place just for not complicating the settings from webmail )

ErrorDocument 400 /error/400.html
ErrorDocument 401 /error/401.html
ErrorDocument 403 /error/403.html
ErrorDocument 404 /error/404.html
ErrorDocument 405 /error/405.html
ErrorDocument 500 /error/500.html
ErrorDocument 503 /error/503.html

<Directory /var/www/mail.domain.com/web> ( change this to /usr/share/squirrelmail )
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all

# ssi enabled
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
Options +Includes
</Directory>
<Directory /var/www/clients/client1/webXX/web> ( u can leave it unchanged)
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all

# ssi enabled
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
Options +Includes
</Directory>

# cgi enabled
<Directory /var/www/clients/clientX/webXX/cgi-bin> ( leave this unchanged )
Order allow,deny
Allow from all
</Directory>
ScriptAlias /cgi-bin/ /var/www/clients/clientX/webXX/cgi-bin/ ( leave this unchanged )
AddHandler cgi-script .cgi
AddHandler cgi-script .pl
# suexec enabled
SuexecUserGroup webXX clientX
# mod_php enabled
AddType application/x-httpd-php .php .php3 .php4 .php5
php_admin_value sendmail_path "/usr/sbin/sendmail -t -i -fwebmaster@mail.domain.com" (change the e-mail address )
php_admin_value upload_tmp_dir /var/www/clients/clientX/webXX/tmp (same unchanged )
php_admin_value session.save_path /var/www/clients/clientX/webXX/tmp (unchanged )


</VirtualHost>




in the end the final vhost settings will look like this:

<quote>

<Directory /usr/share/squirrelmail>
AllowOverride None
Order Deny,Allow
Deny from all
</Directory>

<VirtualHost *:80>
DocumentRoot /usr/share/squirrelmail

ServerName mail.domain.com
ServerAdmin master@domain.com

ErrorLog /var/log/ispconfig/httpd/mail.domain.com/error.log

ErrorDocument 400 /error/400.html
ErrorDocument 401 /error/401.html
ErrorDocument 403 /error/403.html
ErrorDocument 404 /error/404.html
ErrorDocument 405 /error/405.html
ErrorDocument 500 /error/500.html
ErrorDocument 503 /error/503.html

<Directory /usr/share/squirrelmail>
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all

# ssi enabled
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
Options +Includes
</Directory>
<Directory /usr/share/squirrelmail>
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all

# ssi enabled
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
Options +Includes
</Directory>

# cgi enabled
<Directory /var/www/clients/clientX/webXX/cgi-bin>
Order allow,deny
Allow from all
</Directory>
ScriptAlias /cgi-bin/ /var/www/clients/clientX/webXX/cgi-bin/
AddHandler cgi-script .cgi
AddHandler cgi-script .pl
# suexec enabled
SuexecUserGroup webXX clientX
# mod_php enabled
AddType application/x-httpd-php .php .php3 .php4 .php5
php_admin_value sendmail_path "/usr/sbin/sendmail -t -i -fmaster@domain.com"
php_admin_value upload_tmp_dir /var/www/clients/clientX/webXX/tmp
php_admin_value session.save_path /var/www/clients/clientX/webXX/tmp


</VirtualHost>

</quote>

restart httpd and ure done ;)

Accesing http://mail.domain.com u will get the answer http://mail.domain.com/src/login.php

This is strictly for squirrelmail, but i think it can work easilly
NOTE: do not try to set the location directl;y to the src folder, it won t work trust me :) i tryed allready :)


i hope it helps u :) at least for me worked perfectly

tomnhanni
14th September 2009, 19:51
Hi,

add the following lines in /etc/apache2/conf.d/apache2-doc

Alias /webmail /usr/share/squirrelmail/

<Directory "/usr/share/squirrelmail/">
Options Indexes FollowSymlinks
AllowOverride None
Order allow,deny
Allow from all
AddDefaultCharset off
</Directory>

and every virtual domain will have a www.virt-domain.com/webmail

Andrei


I get this:

Warning: Unknown: open_basedir restriction in effect. File(/usr/share/squirrelmail/index.php) is not within the allowed path(s): (/var/www/clients/client2/web2/web:/var/www/clients/client2/web2/tmp:/usr/share/php5:/var/www/typo3_src) in Unknown on line 0

Warning: Unknown: failed to open stream: Operation not permitted in Unknown on line 0

Fatal error: Unknown: Failed opening required '/usr/share/squirrelmail/index.php' (include_path='.:/usr/share/php:/usr/share/pear') in Unknown on line 0

tomnhanni
17th September 2009, 14:10
adding this to apache directives for each Site seems to work nicely

Redirectpermanent /webmail http://MY_IP_ADDRESS/webmail

just make sure a symlink called webmail is set up in apache root im my case /var/www/ (on Debian) to /usr/share/squirrelmail/