how to redirect mail.anydomain to the webmail vhost

Discussion in 'Tips/Tricks/Mods' started by Ovidiu, May 5, 2009.

  1. Ovidiu

    Ovidiu Active Member

    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

    Code:
    <VirtualHost 85.214.146.68:80>
    ServerName webmail
    ServerAlias mail.*
    ErrorLog /var/www/webmail/log/error.log
    ServerAdmin [email protected]
    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
    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?
     
  2. falko

    falko Super Moderator Howtoforge Staff

    Can you replace
    Code:
    </VirtualHost>#
    with
    Code:
    </VirtualHost>
    ?
     
  3. Ovidiu

    Ovidiu Active Member

    silly mistake, but it didn't change a thing, all vhosts get redirected to the webmail login :-(

    anything else I might be doing wrong?
     
  4. falko

    falko Super Moderator Howtoforge Staff

    Does this happen only if you use the webmail subdomain, or also for the mail subdomain?
     
  5. Ovidiu

    Ovidiu Active Member

    I tried

    same result...

    this is weird. here is the exact vhost settigns I was using in ispcfg3 and it worked and still works perfectly:
    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
     
  6. falko

    falko Super Moderator Howtoforge Staff

    No, I meant, does this happen only if you use the webmail subdomain, or also for the mail subdomain in the browser?
     
  7. Ovidiu

    Ovidiu Active Member

    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 :)
     
  8. falko

    falko Super Moderator Howtoforge Staff

    Hm, that's really strange. I have no idea why this is happening.
     
  9. tio289

    tio289 Member

    you can try use only rewrite rules in all vhosts
     
  10. fastgrav

    fastgrav New Member

    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
     
  11. Ovidiu

    Ovidiu Active Member

    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 :)
     
  12. Amorphous

    Amorphous New Member

    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 [email protected] , 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
     
  13. till

    till Super Moderator Staff Member ISPConfig Developer

    @Amorphus: This is all not related to this thread. If you have any problems with creating email accounts, please make a new thread.
     
  14. Amorphous

    Amorphous New Member

    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 [email protected] ( change this with your real e-mail address , eg.: [email protected] )

    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 [email protected]" (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 [email protected]

    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 [email protected]"
    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
     
    Last edited: Aug 25, 2009
  15. tomnhanni

    tomnhanni New Member


    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
     
  16. tomnhanni

    tomnhanni New Member

    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/
     

Share This Page