12 object(s)

How to setup an Apache Virtualhost as proxy

If you want to use apache to set a virtualhost and to use it as proxy, to pass one or more localhosts to internet, all you have to do is to follow few simple rules described below:

  1. create file /etc/apache2/sites-available/VIRTUALHOST_NAME.conf
  2. sudo a2ensite virtual_host_file_name
    • to disable an existing conf file sudo a2dissite virtual_host_file_name
  3. move file in /etc/apache2/sites-enabled/VIRTUALHOST_NAME.conf
  4. install ssl module sudo a2enmod ssl
  5. sudo service apache2 reload

Other commands for apache:


<VirtualHost *:80>
        # for a single domain without different subdomains
        Redirect permanent / https://URL_ADDRESS
        # for multiple subdomains
        #RewriteEngine on
        #RewriteCond %{HTTP_HOST} ^(.+)\.airtouchmedia\.com$
        #RewriteRule ^/(.*)$$1 [R=301,L]

<IfModule mod_ssl.c>
        <VirtualHost *:443>

                ServerAdmin EMAIL
                ServerName URL_ADDRESS

                ProxyPreserveHost On
                ProxyPass /
                ProxyPassReverse /

                SSLEngine on
                SSLCertificateFile /home/ubuntu/certificates/certificate.crt
                SSLCertificateKeyFile /home/ubuntu/certificates/certificate.key
                SSLCertificateChainFile /home/ubuntu/certificates/


This article can be found as well on Gist