Best way to redirect <client_site>/roundcube to webmail.<client_site> for all sites?

Discussion in 'Installation/Configuration' started by snowweb, Aug 19, 2020.

  1. snowweb

    snowweb Member

    I'm migrating all clients from previous non-ISPConfig VPS. On that VPS all sites were automatically assigned redirection of Roundcube to webmail.<client_site> and to make the migration seamless for them, I would like to prepare the same on this new ISPConfig VPS.
    What would be the recommended way to achieve this? Thanks.
     
  2. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

    I don't do this automatically, but if a client requests it, i set up a web domain "webmail.client-site.com" with this as directive:
    Code:
    DocumentRoot "/var/lib/roundcube"
    . This way, I can add a LE certificate that's just for their webmail, and not for other sub-/aliasdomains or the webmail of others.
     
  3. snowweb

    snowweb Member

    I see. That could work well for me. So, where do you usually put the directive, .htaccess, /etc/apache/sites-available/<client_site>.vhost file or is it somewhere in ISPConfig?

    Thanks ThOm.
     
  4. Jesse Norell

    Jesse Norell ISPConfig Developer Staff Member ISPConfig Developer

    You could probably incorporate it into your site vhost template (search for making conf-custom templates), and use <If> statements to match a 'webmail' HTTP_HOST and set the docroot and do whatever you need accordingly. You'll have to add the vhost so ISPConfig ads that name into the ssl certificate (you could probably automate this step with an interface plugin). And don't forget to add 'webmail' to your dns templates and into your existing dns zones, or your ssl certificate will never issue.
     
    snowweb and Th0m like this.
  5. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

    I do this under Websites -> example.com -> Options -> Apache Directives
     
    snowweb likes this.
  6. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

    This sounds interesting though, I never looked into that. Maybe you can write a HTF tutorial on it @Jesse Norell ?
     
  7. snowweb

    snowweb Member

    I'll go with your usual way for now but I'm definitely interested in automating this in the future. Maybe I'll play with Jesse's idea later.
    Thanks guys!
     
    Th0m likes this.
  8. snowweb

    snowweb Member

    I'm now able to access roundcube on the Webmail subdomain. The only problem is the Document root is applied no only to the webmail domain, but also to the main site. I think ideally, there needs to be a field where "apache directives" can be entered for each subdomain?
    Since there isn't, should I put it directly in /etc/apache2/sites-available/mydomain.com.vhost? Will it get over-written by ISPConfig at anytime or is it safe to do?
     
  9. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

    You should add webmail.example.com as website, not as subdomain of example.com.

    Never mess with one vhost, because changes will be overwritten and things can stop working.
     
    snowweb likes this.
  10. Jesse Norell

    Jesse Norell ISPConfig Developer Staff Member ISPConfig Developer

    Or change your vhost template to handle it correctly, but as @Th0m said, don't edit the file directly or you'll loose your changes.
     
    snowweb and Th0m like this.
  11. snowweb

    snowweb Member

    I tried using httpd <if> statements as below in the apache directives box, but as soon as it see's the DocumentRoot is refuses to copy it into the vhost file. If I replace that with something else it gets copied (but obviously doesn't help me).
    Then (before I saw your warning above) I tried editing the vhost file directly, which worked a treat, except it seems at some point it will stop working (maybe at server restart)?

    The changes I made were to <VirtualHost *:443>. I commented out the document root and added the new one and I commented out the original ServerAlias and left the "webmail" one.

    Is there somewhere else I can make those changes? I don't think I can do this in the apache directive area in the panel because it will redirect the entire domain to roundcube and most customers will want their own content on their main domain. Any thoughts please?
     
  12. snowweb

    snowweb Member

    I just saw this! Sorry!
    This could work. I will give it a try. Thanks.
     
  13. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

    It should work fine then.

    If you want to add it to all vhosts (but again, you would have to be 100% sure that the DNS records are added), you can create a custom vhost and place this in the conf-custom folder, but that would apply to all sites you add.
     
  14. snowweb

    snowweb Member

    Decided to initially keep it simple. I'll just get it working individually per domain to start with and will look into more elegant solutions later. With this in mind I:
    • Added new site but specified the domain as webmail.example.com. I checked Let's Encrypt and set the DocumentRoot to "/var/lib/roundcube"
    • Checked the redirect to SSL option
    • Added an A record into the existing example.com zone, for 'webmail'
    Upon checking, the SSL certificate being used turned out to be the one my ISPConfig was using, not the one for example.com, so I went back to Sites > webmail.example.com to check and LE was unchecked! I checked it again, closed the record and returned to it again after the ongoing tasks were completed and found it unchecked again!

    Not sure what might be causing this. Any ideas? Thanks.
     
  15. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

    snowweb likes this.
  16. snowweb

    snowweb Member

    Th0m likes this.

Share This Page