Setting up Apache

The following configurations works for HTTPS (with an HTTP redirection).

Create a new virtual host file:

sudo nano /etc/apache2/sites-available/airsonic.conf

Paste the following configuration in the virtual host file:

<VirtualHost *:80>
   Redirect permanent /

<VirtualHost *:443>
    SSLEngine On
    SSLCertificateFile cert.pem
    SSLCertificateKeyFile key.pem
    SSLProxyEngine on
    LogLevel warn
    CustomLog ${APACHE_LOG_DIR}/airsonic-access.log combined
    ErrorLog ${APACHE_LOG_DIR}/airsonic-error.log
    ProxyPass /airsonic
    ProxyPassReverse /airsonic
    RequestHeader set X-Forwarded-Proto "https"

You will need to make a couple of changes in the configuration file:

  • Replace with your own domain name.
  • Be sure to set the right path to your cert.pem and key.pem files.
  • Change /airsonic following your airsonic server path.
  • Change following you airsonic server location, port and path.

    NOTE: you could only add ProxyPass and ProxyPassReverse lines to your existing configuration:

    ProxyPass         /airsonic
    ProxyPassReverse  /airsonic

Activate the host:

sudo a2ensite airsonic.conf

Activate apache2 proxy, proxy_http and ssl module:

sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod ssl
sudo a2enmod headers

Restart the Apache2 service:

sudo systemctl restart apache2.service