Roundcube Community Forum

News and Announcements => General Discussion => Topic started by: NichH on July 21, 2025, 08:30:39 AM

Title: How can I run roundcube as a subdomain in apache?
Post by: NichH on July 21, 2025, 08:30:39 AM
I have a default current installation of Roundcube in Debian 12 using apt. I was accessing it through a reverse proxy which I am dismantling. This did a redirect from webmail.mydomain.com to mail-www.mydomain.com/roundcube. I had to make a small config adjustment in roundcube for this to work ($config['request_path'] = '/';).

I am now running pfSense with HAproxy and I am not very clever with it so I have not worked out how to make it switch the FQDN's.

What I am trying to do is set up a virtualhost in apache 2.4 for webmail.mydomain.com, dragging in the settings from /etc/apache2/conf-available/roundcube.conf

What I have ended up with is:
<VirtualHost *:80>

    DocumentRoot /var/lib/roundcube
    ServerName webmail.mydomain.com
   
    <Directory /var/www/roundcube>
        Options FollowSymLinks
        AllowOverride None
        Require all granted
    </Directory>

    <Directory /var/lib/roundcube/public_html/>
      Options +FollowSymLinks
      # This is needed to parse /var/lib/roundcube/.htaccess. See its
      # content before setting AllowOverride to None.
      AllowOverride All
      <IfVersion >= 2.3>
        Require all granted
      </IfVersion>
      <IfVersion < 2.3>
        Order allow,deny
        Allow from all
      </IfVersion>
    </Directory>

    # Protecting basic directories (not needed when the document root is
    # /var/lib/roundcube/public_html):
    <Directory /var/lib/roundcube/config>
      Options -FollowSymLinks
      AllowOverride None
    </Directory>

    <Directory /var/lib/roundcube/temp>
      Options -FollowSymLinks
      AllowOverride None
      <IfVersion >= 2.3>
        Require all denied
      </IfVersion>
      <IfVersion < 2.3>
        Order allow,deny
        Deny from all
      </IfVersion>
    </Directory>

    <Directory /var/lib/roundcube/logs>
      Options -FollowSymLinks
      AllowOverride None
      <IfVersion >= 2.3>
        Require all denied
      </IfVersion>
      <IfVersion < 2.3>
        Order allow,deny
        Deny from all
      </IfVersion>
    </Directory>
    ErrorLog /var/log/apache2/roundcube.mydomain.com.error.log
    LogLevel emerg
    CustomLog /var/log/apache2/roundcube.mydomain.com.access.log "combined"

</VirtualHost>

This does not work and I get the default webserver page.

If I change the first directory block to:
    <Directory />
        Options FollowSymLinks
        AllowOverride None
        Require all granted
    </Directory>

Then it all works but I don't think it is the right think to do as it seems to me to open up the whole filesystem.

What is the way to get this working safely?

Title: Re: How can I run roundcube as a subdomain in apache?
Post by: alec on July 22, 2025, 01:45:14 AM
DocumentRoot /var/lib/roundcube/public_html
Title: Re: How can I run roundcube as a subdomain in apache?
Post by: NichH on July 22, 2025, 10:57:46 AM
Thanks. That worked. And I've dropped all the bits that were duplicated from /etc/apache2/conf-available/.