2

I have a domain: example.com. There’s also a subdomain, admin.example.com:

<VirtualHost *:80>
    ServerName admin.example.com
    ServerAlias admin
</VirtualHost>

Now I want to make postfixadmin control panel available at admin.example.com/postfix. The default config in /etc/apache2/conf.d/postfixadmin is:

Alias /postfixadmin /usr/share/postfixadmin

How should I change it? What I want is something like:

Alias admin/postfix /usr/share/postfixadmin

Edit: I know that I can just create a symlink under document root, pointing to /usr/share/postfixadmin, but I’m looking for a solution through the means of Apache config.

3 Answers 3

3

There are probably multiple ways to accomplish this. Two ways I can think of:

Symlink

You could set a document root for the admin VirtualHost and then create a postfixadmin symlink to /usr/share/postfixadmin. Something like:

<VirtualHost *:80>
    ServerName admin.example.com
    ServerAlias admin
    DocumentRoot /var/www/admin

    <Directory /var/www/admin>
        Options +FollowSymLinks
    </Directory>
</VirtualHost>

Directory Security

Keeping the original alias, you could set some diretory security per virtual hosts to only allow the admin virtual host to access the directory. Something like:

Admin VirtualHost

<VirtualHost *:80>
    ServerName admin.example.com
    ServerAlias admin

    <Directory /usr/share/postfixadmin>
        Order Deny,Allow
        Allow from All
    </Directory>
</VirtualHost>

Main VirtualHost

<VirtualHost *:80>
    ServerName example.com

    <Directory /usr/share/postfixadmin>
        Order Deny,Allow
        Deny from All
    </Directory>
</VirtualHost>
0

I know it is an old question, but I think it is still relevant. Currently, Postfixadmin is still accessed through the alias Alias /postfixadmin /php/directory/of/postfixadmin. This alias is now located in /etc/apache2/conf-available/postfixadmin.conf. It's not a simlink - it's an alias in apache config. With this approach you can access postfixadmin with the URL path /postfixadmin in any virtual hosts in your server. The same is true with phpmyadmin or with any other application that uses this Alias approach. So, you need one installation for all virtual hosts: you edit /etc/postfixadmin/config.inc.php and /etc/postfixadmin/dbconfig.inc.php and run /etc/postfixadmin/setup.php only once for all virtual hosts. However, if PHP has a different configuration or runs as a different user or Apache has different directives in some virtual host, you might need to check the configurations that are specific to this virtual host. I suspect that this was the issue that the OP had. I noticed that postfixadmin fails silently when session does not work and, also, the access rights to the config files, especially for the database, are tight. If the PHP user does not have the appropriate privileges, it will fail.

-1

Leave the original virtualhost definition the way it is and place a directory inside your document root entitled "postfix". Put the postfixadmin files in there. This will then render under your requested admin.example.com/postfix

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .