Skip to content
Snippets Groups Projects
apache.conf 4.21 KiB
Newer Older
# Following variables MUST be modified according to your setup
Define funkwhale-sn funkwhale.yourdomain.com

# Following variables should be modified according to your setup and if you
# use different configuration than what is described in our installation guide.
Define funkwhale-api http://localhost:5000
Define funkwhale-api-ws ws://localhost:5000
Define MUSIC_DIRECTORY_PATH /srv/funkwhale/data/music
# HTTP requests redirected to HTTPS
<VirtualHost *:80>
   ServerName ${funkwhale-sn}
   # Default is to force https
   RewriteEngine on
   RewriteCond %{SERVER_NAME} =${funkwhale-sn}
   RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]

   <Location "/.well-known/acme-challenge/">
      Options None
      Require all granted
   </Location>
</VirtualHost>


<IfModule mod_ssl.c>
<VirtualHost *:443>
   ServerName ${funkwhale-sn}

   # Path to ErrorLog and access log
   ErrorLog ${APACHE_LOG_DIR}/funkwhale/error.log
   CustomLog ${APACHE_LOG_DIR}/funkwhale/access.log combined

   # TLS
   # Feel free to use your own configuration for SSL here or simply remove the
   # lines and move the configuration to the previous server block if you
Reg's avatar
Reg committed
   # don't want to run funkwhale behind https (this is not recommended)
   # have a look here for let's encrypt configuration:
   # https://certbot.eff.org/lets-encrypt/debianstretch-apache.html
   SSLEngine on
   SSLProxyEngine On
   SSLCertificateFile /etc/letsencrypt/live/${funkwhale-sn}/fullchain.pem
   SSLCertificateKeyFile /etc/letsencrypt/live/${funkwhale-sn}/privkey.pem
   Include /etc/letsencrypt/options-ssl-apache.conf

   # Tell the api that the client is using https
   RequestHeader set X-Forwarded-Proto "https"

   # Configure Proxy settings
   # ProxyPreserveHost pass the original Host header to the backend server
   ProxyVia On
   ProxyPreserveHost On
   <IfModule mod_remoteip.c>
      RemoteIPHeader X-Forwarded-For
   </IfModule>

   # Turning ProxyRequests on and allowing proxying from all may allow
   # spammers to use your proxy to send email.
      AddDefaultCharset off
      Order Allow,Deny
      Allow from all
   </Proxy>

R En's avatar
R En committed
   # Activating WebSockets
   <Location "/api/v1/activity">
	   ProxyPass ${funkwhale-api-ws}/api/v1/activity
   </Location>
R En's avatar
R En committed

R En's avatar
R En committed
   <Location "/">
      # similar to nginx 'client_max_body_size 100M;'
      LimitRequestBody 104857600
R En's avatar
R En committed
      ProxyPass ${funkwhale-api}/
      ProxyPassReverse ${funkwhale-api}/
   </Location>
   <Location "/federation">
      ProxyPass ${funkwhale-api}/federation
      ProxyPassReverse ${funkwhale-api}/federation
   </Location>
   # You can comment this if you don't plan to use the Subsonic API
   <Location "/rest">
      ProxyPass ${funkwhale-api}/api/subsonic/rest
      ProxyPassReverse ${funkwhale-api}/api/subsonic/rest
   </Location>

   <Location "/.well-known/">
      ProxyPass ${funkwhale-api}/.well-known/
      ProxyPassReverse ${funkwhale-api}/.well-known/
   <Location "/front">
      ProxyPass  "!"
   </Location>
R En's avatar
R En committed
   Alias /front /srv/funkwhale/front/dist

   <Location "/media">
      ProxyPass  "!"
   </Location>
   Alias /media /srv/funkwhale/data/media

   <Location "/staticfiles">
      ProxyPass  "!"
   </Location>
   Alias /staticfiles /srv/funkwhale/data/static

   # Setting appropriate access levels to serve frontend
   <Directory "/srv/funkwhale/data/static">
      Require all granted
   </Directory>

   <Directory /srv/funkwhale/front/dist>
      Options FollowSymLinks
      AllowOverride None
      Require all granted
   </Directory>

R En's avatar
R En committed
   <Directory /srv/funkwhale/data/media>
      Options FollowSymLinks
      AllowOverride None
      Require all granted
   </Directory>

   # XSendFile is serving audio files
   # WARNING : permissions on paths specified below overrides previous definition,
   # everything under those paths is potentially exposed.
   # Following directive may be needed to ensure xsendfile is loaded
   #LoadModule xsendfile_module modules/mod_xsendfile.so
   <IfModule mod_xsendfile.c>
      XSendFile On
      XSendFilePath /srv/funkwhale/data/media
      XSendFilePath ${MUSIC_DIRECTORY_PATH}
      SetEnv MOD_X_SENDFILE_ENABLED 1
   </IfModule>
</VirtualHost>
</IfModule>