--- title: 06 Media description: published: true date: 2023-05-03T03:01:17.550Z tags: editor: markdown dateCreated: 2023-05-03T01:58:51.186Z --- # Ampache Ampache is a music server, Kind of like your own self hosted Spotify. It supports practically everything, from podcasts, to several music streaming protocols, transcoding, It even has a web player, music management, ratings and smart playlists. It truly is amazing. First we need to create a network for the service. sudo docker network create --subnet=172.31.0.0/16 ampache Add the ampache network to the mariadb and nginx compose files ~/docker/mariadb/docker-compose.yml ampache: ipv4_address: 172.31.0.30 ampache: external: true name: ampache ~/docker/nginx/docker-compose.yml ampache: ipv4_address: 172.31.0.20 ampache: external: true name: ampache Be sure to add them to the correct places, under the 2 networks: tags 1 under service and the other stands alone. Take a look at the nextcloud example. Now simply restart the containers to make it take effect sudo docker-compose -f ~/docker/nginx/docker-compose.yml restart sudo docker-compose -f ~/docker/mariadb/docker-compose.yml restart Next we are going to create some folders mkdir -p ~/docker/ampache Now create a compose file for Ampache nano ~/docker/ampache/docker-compose.yml Add in the following text version: '3' services: ampache: image: ampache/ampache:latest container_name: ampache restart: always volumes: - /data/ampache/config:/var/www/config - /data/ampache/log:/var/log/ampache - /data/music:/media networks: ampache: ipv4_address: 172.31.0.10 networks: ampache: external: true name: ampache ipam: config: - subnet: 172.31.0.0/16 Now we need to add in the server blocks to the Nginx config file so open te file sudo nano /data/nginx/nginx.conf And add in the following blocks within the html block server { server_name example.com; listen 443 ssl; ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; client_max_body_size 100M; autoindex off; location / { proxy_pass http://ampache:80; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $http_host; proxy_set_header Host $http_host; proxy_max_temp_file_size 0; proxy_redirect off; if ( !-d $request_filename ) { rewrite ^/rest/(.*).view$ /rest/index.php?action=$1 last; rewrite ^/rest/fake/(.+)$ /play/$1 last; } rewrite ^(.*) $1 break; rewrite ^/play/ssid/(.*)/type/(.*)/oid/([0-9]+)/uid/([0-9]+)/client/(.*)/player/(.*)/name/(.*)$ /play/index.php?ssid=$1&type=$2&oid=$3&uid=$4&client=$5&player=$6&name=$7 last; } } server { listen 80; server_name houtworm.vip; return 301 https://houtworm.vip$request_uri; } Be sure to place it correctly, don't put it inside other server blocks. but it under the other server blocks. Now we are going to start the container. sudo docker-compose -f ~/docker/ampache/docker-compose.yml up -d Now we need to give the right permissions to the ampache config folder so run the following command sudo chown -R 33:33 /data/ampache/config Ampache should be accessable from your browser using the domain you chose, But first we need to create a database, user and set the permissions. You can get into the database with the following command (only if mariadb is running) sudo docker exec -it mariadb mysql -p Enter the Mysql root password you provided during the creation of the mariadb container and you should be in. Now run the following commands to create a database, create a user with privileges, and make them take effect. create database ampache; create user ampache@'%' identified by 'set your ampache database password here'; grant all privileges on ampache.* to ampache@'%'; flush privileges; You can exit the mysql prompt with exit; and then pressing enter. Now we just need to go to example.com and follow the steps The Database is ampache, the user is ampache, The hostname is 172.31.0.30 and the password is what you gave it. uncheck create database and click on inject database. Next you leave web path empty and simply click on generate config file One last step is forcing HTTPS, else it will give problems since we are running from behind a proxy sudo nano /data/ampache/config/config.php Uncomment the following line force_ssl = "true" Now Ampache should be all ready to go # Jellyfin WIP!