Airsonic

Music streaming.

See Airsonic Docker and Documentation.

Ports

Files

Docker Creation

You can copy your existing configuration to docker /config directory adjusting for paths.

Docker Compose
airsonic:
  image: linuxserver/airsonic
  restart: unless-stopped
  environment:
    - PUID=1000
    - PGID=1000
    - JAVA_OPTS=-Xmx256m -Xms256m
    - TZ=America/Los_Angeles
  volumes:
    - /data/services/airsonic/config:/config
    - /data/services/airsonic/playlists:/playlists
    - /data/media/podcasts:/podcasts:ro
    - /data/media/music:/music:ro
    - /data/other/media:/media:ro
    - /etc/localtime:/etc/localtime:ro
  • Proxy will forward traffic to the container, so no ports need to be exposed.

  • Use environment CONTEXT_PATH=URL_BASE if airsonic is serving from a subpath.

  • Limit airsonic to 256MB for initial memory size, and heap size. See Java Xmx and Xms options.

Reverse Proxy Setup

Allows you to isolate your containers as well as wrap connections in SSL. See NGINX for more details. See Setup Base Proxy Control for basic proxy configuration.

Enable Forward Headers

Airsonic must be configured to expect requests through a proxy otherwise connections will fail through a reverse proxy. Enable this and restart the service before testing proxy configuration. Start the service to create a new file if it doesn’t exist.

0644 root root /data/airsonic.properties
server.use-forward-headers=true

Using Subdomains

0644 root root nginx/conf.d/reverse-proxy.conf
server {
  listen                                 443 ssl http2;
  server_name                            airsonic.{DOMAIN} airsonic;
  location / {
    proxy_bind                           {NGINX PROXY IP};
    proxy_set_header X-Real-IP           $remote_addr;
    proxy_set_header X-Forwarded-For     $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto   https;
    proxy_set_header X-Forwarded-Host    $http_host;
    proxy_set_header Host                $http_host;
    proxy_set_header X-Forwarded-Server  $host;
    proxy_max_temp_file_size             0;
    proxy_pass                           http://airsonic:4040;
    add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;";
    add_header X-Content-Type-Options    "nosniff";
    add_header X-Frame-Options           SAMEORIGIN;
    add_header X-XSS-Protection          "1; mode=block";
    add_header X-Robots-Tag              none;
  }
}

Using Subpaths

0644 root root nginx/conf.d/reverse-proxy.conf
server {
  listen                                 443 ssl http2;
  server_name                            airsonic.{DOMAIN} airsonic;
  location /airsonic {
    proxy_bind                           {NGINX PROXY IP};
    proxy_set_header X-Real-IP           $remote_addr;
    proxy_set_header X-Forwarded-For     $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto   https;
    proxy_set_header X-Forwarded-Host    $http_host;
    proxy_set_header Host                $http_host;
    proxy_set_header X-Forwarded-Server  $host;
    proxy_max_temp_file_size             0;
    proxy_pass                           http://airsonic:4040;
    add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;";
    add_header X-Content-Type-Options    "nosniff";
    add_header X-Frame-Options           SAMEORIGIN;
    add_header X-XSS-Protection          "1; mode=block";
    add_header X-Robots-Tag              none;
  }
}

Note

Use environment CONTEXT_PATH=URL_BASE if airsonic is serving from a subpath.

Postgres Backend

Postgres may be used to store airsonic data in a centralized location. This assumes that Postgresql is already configured, with an empty database for airsonic to use (see Creating A Database).

Docker Compose Add Postgres Network.
networks:
  db:
    external: True
airsonic:
  image: linuxserver/airsonic
  networks:
    - db
0644 root root /data/airsonic.properties
DatabaseConfigType=embed
DatabaseConfigEmbedDriver=org.postgresql.Driver
DatabaseConfigEmbedUsername={USER}
DatabaseConfigEmbedPassword={PASS}
DatabaseConfigEmbedUrl=jdbc:postgresql://{DB IP}:{DB PORT}/airsonic?stringtype=unspecified
DatabaseUsertableQuote="

Note

Launch airsonic and shutdown after it finishes starting up. The initial DB incorrectly defines two postgres datatypes. Correct this by executing the following commands below when Airsonic is shutdown.

Set correct datatypes for columns in postgres.
ALTER TABLE system_avatar ALTER COLUMN data TYPE bytea USING NULL;
ALTER TABLE custom_avatar ALTER COLUMN data TYPE bytea USING NULL;

Restart Airsonic to complete DB setup.

References

  1. Airsonic Configuration File

  2. Airsonic reverse proxy

  3. Airsonic nginx reverse proxy

  4. Airsonic Database Support