Configure Apache for running Plesk as a Subdomain

Running Plesk on its own port, such as www.example.com:8443, is a pain for various reasons -- it would be much nicer to use plesk.example.com instead. We can use a reverse proxy to accomplish this.

The following instructions apply to a SuSE 10.0 host running Plesk 8. Using phpInfo() I found out that my Apache 2.0 wasn't running mod_proxy, and I started looking for information on how to recompile Apache to include the required module. Then I found out that mod_so was running, and that many modules were already installed on the server as Dynamic Shared Objects (DSOs), e.g. mod_proxy.so.

But how do you activate them? I tried YaST and surely found functionality to enable DSOs in an "advanced" section. The trouble with these tools is that you never know whether they'll trash your existing setup or not... I took a deep breath and saved my changes, and indeed, it broke my site. Thanks to Subversion, I was easily able to restore the old settings, and I found out which file was controlling Apache.

Let's implement the Plesk subdomain:

  1. Enable Apache's mod_proxy and mod_proxy_http modules: edit /etc/sysconfig/apache2 and add proxy proxy_http to the APACHE_MODULES list
  2. Create a plesk subdomain with the following properties:
    • SSL support, single directory
    • PHP
    • CGI
  3. Create the file /srv/www/vhosts/example.com/subdomains/plesk/conf/vhost.conf with the following content
    <IfDefine !NOSSL>
        <IfModule mod_ssl.c>
            <IfModule mod_proxy.c>
    
                SSLProxyEngine on
                ProxyRequests off
                ProxyPass        / https://example.com:8443/
                ProxyPassReverse / https://example.com:8443/
    
            </IfModule>
        </IfModule>
    </IfDefine>
    
  4. Create the appropriate include directive for vhost.conf:
    # /usr/local/psa/admin/sbin/websrvmng --reconfigure-vhost --vhost-name=example.com
  5. Restart Apache to activate our changes:
    # /etc/init.d/apache2 restart

According to the Plesk documentation, there should be a pair of configuration files, vhost.conf and vhost_ssl.conf, for separately controlling the plain and SSL versions of each subdomain, but in Plesk 8.0.1, the same file is used for both. You could manually edit /var/www/vhosts/example.com/conf/httpd.include, but Plesk rewrites that file whenever you reconfigure the domain.