mirror of
https://github.com/Adam-Ant/media-server-in-a-box
synced 2024-12-20 14:44:34 +00:00
Merge branch 'proxy'
This commit is contained in:
commit
4b71cf2e8f
@ -1,9 +1,11 @@
|
|||||||
# Media Server in a box
|
# Media Server in a box
|
||||||
|
|
||||||
A script and accompanying docker-compose file to go from a bare Docker install to a ready to be configured media server in seconds. Write up to follow.
|
A script and accompanying docker-compose file to go from a bare Docker install to a ready to be configured media server in seconds. Write up to follow.
|
||||||
|
|
||||||
|
**This Version uses a reverse proxy and requires DNS configuration**
|
||||||
|
|
||||||
## One liner to get started:
|
## One liner to get started:
|
||||||
|
|
||||||
*Note: This needs to be run as root*
|
*Note: This needs to be run as root*
|
||||||
|
|
||||||
``` curl -sSL https://raw.githubusercontent.com/Adam-Ant/media-server-in-a-box/master/start.sh | bash ```
|
``` curl -sSL https://raw.githubusercontent.com/Adam-Ant/media-server-in-a-box/proxy/start.sh | bash ```
|
||||||
|
@ -14,8 +14,6 @@ services:
|
|||||||
- data
|
- data
|
||||||
- container:media
|
- container:media
|
||||||
restart: always
|
restart: always
|
||||||
ports:
|
|
||||||
- "6789:6789"
|
|
||||||
|
|
||||||
deluge:
|
deluge:
|
||||||
image: adamant/deluge
|
image: adamant/deluge
|
||||||
@ -25,11 +23,6 @@ services:
|
|||||||
- data
|
- data
|
||||||
- container:media
|
- container:media
|
||||||
restart: always
|
restart: always
|
||||||
ports:
|
|
||||||
- "8112:8112"
|
|
||||||
- "58846:58846"
|
|
||||||
- "53160:53160"
|
|
||||||
- "53160:53160/udp"
|
|
||||||
|
|
||||||
sickrage:
|
sickrage:
|
||||||
image: adamant/sickrage
|
image: adamant/sickrage
|
||||||
@ -40,8 +33,6 @@ services:
|
|||||||
- data
|
- data
|
||||||
- container:media
|
- container:media
|
||||||
restart: always
|
restart: always
|
||||||
ports:
|
|
||||||
- "8081:8081"
|
|
||||||
|
|
||||||
couchpotato:
|
couchpotato:
|
||||||
image: adamant/couchpotato
|
image: adamant/couchpotato
|
||||||
@ -52,20 +43,6 @@ services:
|
|||||||
- data
|
- data
|
||||||
- container:media
|
- container:media
|
||||||
restart: always
|
restart: always
|
||||||
ports:
|
|
||||||
- "5050:5050"
|
|
||||||
|
|
||||||
headphones:
|
|
||||||
image: adamant/headphones
|
|
||||||
depends_on:
|
|
||||||
- deluge
|
|
||||||
- nzbget
|
|
||||||
volumes_from:
|
|
||||||
- data
|
|
||||||
- container:media
|
|
||||||
restart: always
|
|
||||||
ports:
|
|
||||||
- "8181:8181"
|
|
||||||
|
|
||||||
radarr:
|
radarr:
|
||||||
image: adamant/radarr
|
image: adamant/radarr
|
||||||
@ -88,9 +65,16 @@ services:
|
|||||||
- data
|
- data
|
||||||
- container:media
|
- container:media
|
||||||
restart: always
|
restart: always
|
||||||
network_mode: "host"
|
|
||||||
ports:
|
ports:
|
||||||
|
- "1900:1900/udp"
|
||||||
|
- "3005:3005"
|
||||||
|
- "5353:5353/udp"
|
||||||
|
- "8324:8324"
|
||||||
- "32400:32400"
|
- "32400:32400"
|
||||||
|
- "32410:32410/udp"
|
||||||
|
- "32412-32414:32412-32414/udp"
|
||||||
|
- "32469:32469"
|
||||||
|
|
||||||
|
|
||||||
plexpy:
|
plexpy:
|
||||||
image: adamant/plexpy
|
image: adamant/plexpy
|
||||||
@ -99,5 +83,11 @@ services:
|
|||||||
volumes_from:
|
volumes_from:
|
||||||
- data
|
- data
|
||||||
restart: always
|
restart: always
|
||||||
|
|
||||||
|
web:
|
||||||
|
image: nginx:alpine
|
||||||
|
volumes:
|
||||||
|
- $VOLDIR/launcher/nginx.cfg:/etc/nginx/conf.d/media.conf
|
||||||
|
restart: always
|
||||||
ports:
|
ports:
|
||||||
- "8182:8181"
|
- "80:80"
|
||||||
|
94
nginx.cfg
Normal file
94
nginx.cfg
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
resolver 127.0.0.1;
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name plex.genie;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
set $test "";
|
||||||
|
|
||||||
|
# If a request to / comes in, 301 redirect to the main plex page,
|
||||||
|
# but only if it doesn't contain the X-Plex-Device-Name header or query argument.
|
||||||
|
# This fixes a bug where you get permission issues when accessing the web dashboard.
|
||||||
|
if ($http_x_plex_device_name = '') {
|
||||||
|
set $test A;
|
||||||
|
}
|
||||||
|
if ($arg_X-Plex-Device-Name = '') {
|
||||||
|
set $test "${test}B";
|
||||||
|
}
|
||||||
|
if ($test = AB) {
|
||||||
|
rewrite ^/$ http://$http_host/web/index.html;
|
||||||
|
}
|
||||||
|
|
||||||
|
proxy_set_header Host $http_host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
|
||||||
|
proxy_pass http://plex:32400;
|
||||||
|
|
||||||
|
# Plex proxy settings.
|
||||||
|
proxy_redirect off;
|
||||||
|
proxy_buffering off;
|
||||||
|
|
||||||
|
## Required for Websockets
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection "upgrade";
|
||||||
|
proxy_read_timeout 36000s; ## Timeout after 10 hours
|
||||||
|
}
|
||||||
|
}
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name deluge.genie;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://deluge:8112;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name sickrage.genie;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://sickrage:8081;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name nzbget.genie;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://nzbget:6791;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name plexpy.genie;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://plexpy:8181;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name couchpotato.genie;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://couchpotato:5050;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name headphones.genie;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://headphones:8181;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name radarr.genie;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://radarr:7878;
|
||||||
|
}
|
||||||
|
}
|
22
start.sh
22
start.sh
@ -4,8 +4,8 @@
|
|||||||
# Prereqs: docker, docker-compose, curl (https)
|
# Prereqs: docker, docker-compose, curl (https)
|
||||||
|
|
||||||
export VOLDIR="/volumes/media-server"
|
export VOLDIR="/volumes/media-server"
|
||||||
SERVICES=("couchpotato" "deluge" "headphones" "nzbget" "plex" "plexpy" "sickrage" "launcher" "radarr")
|
SERVICES=("couchpotato" "deluge" "nzbget" "plex" "plexpy" "sickrage" "launcher")
|
||||||
SERVICEUID=("745" "647" "526" "236" "787" "426" "439" "0" "326")
|
SERVICEUID=("745" "647" "236" "787" "426" "439" "0")
|
||||||
|
|
||||||
[[ $EUID -ne 0 ]] && echo "Please run this script as root" && exit 1
|
[[ $EUID -ne 0 ]] && echo "Please run this script as root" && exit 1
|
||||||
|
|
||||||
@ -16,11 +16,10 @@ docker version &> /dev/null
|
|||||||
docker-compose version &> /dev/null
|
docker-compose version &> /dev/null
|
||||||
[[ $? -ne 0 ]] && echo "docker-compose not found. Please check your configuration." && exit 1
|
[[ $? -ne 0 ]] && echo "docker-compose not found. Please check your configuration." && exit 1
|
||||||
# Check if media container is configured
|
# Check if media container is configured
|
||||||
[[ $(docker ps -a --filter="name=media" | wc -l) != "2" ]] && echo "Cannot find a media container - please configure one with your media mounted at /media inside the container before running this script (to keep the size down use tianon/true)" && exit 1
|
[[ $(docker ps -a --filter="name=media" | wc -l) != "2" ]] && echo "Cannot find a media container - please configure one with your media mounted at /media inside the container. to keep the size down use tianon/true)" && exit 1
|
||||||
|
|
||||||
# Check if volumes folder exists
|
# Check if volumes folder exists
|
||||||
[[ ! -d $VOLDIR ]] && echo "Creating volumes folder..." && mkdir -p $VOLDIR
|
[[ ! -d $VOLDIR ]] && echo "Creating volumes folder..." && mkdir -p $VOLDIR
|
||||||
[[ ! -d $VOLDIR/couchpotato ]]
|
|
||||||
|
|
||||||
slen=${#SERVICES[@]}
|
slen=${#SERVICES[@]}
|
||||||
for ((i=0; i<$slen; i++)); do
|
for ((i=0; i<$slen; i++)); do
|
||||||
@ -28,6 +27,15 @@ for ((i=0; i<$slen; i++)); do
|
|||||||
[[ $( ls -dn $VOLDIR/${SERVICES[$i]} | awk '{print $3}') != ${SERVICEUID[$i]} ]] && echo "Chowning $VOLDIR/${SERVICES[$i]} to user ${SERVICEUID[$i]}" && chown -R ${SERVICEUID[$i]}:${SERVICEUID[$i]} $VOLDIR/${SERVICES[$i]}
|
[[ $( ls -dn $VOLDIR/${SERVICES[$i]} | awk '{print $3}') != ${SERVICEUID[$i]} ]] && echo "Chowning $VOLDIR/${SERVICES[$i]} to user ${SERVICEUID[$i]}" && chown -R ${SERVICEUID[$i]}:${SERVICEUID[$i]} $VOLDIR/${SERVICES[$i]}
|
||||||
done
|
done
|
||||||
|
|
||||||
[[ ! -a $VOLDIR/launcher/media-compose.yml ]] && echo "Downloading media-compose.yml.." && curl -sSL https://raw.githubusercontent.com/Adam-Ant/media-server-in-a-box/master/docker-compose.yml > $VOLDIR/launcher/media-compose.yml
|
#Since we are not using net=host, we need to whitelist the subnet in plex. ##TODO## Make this overrideable with commandline argument
|
||||||
echo "Starting services..."
|
[[ ! -a $VOLDIR/plex/Plex\ Media\ Server/Preferences.xml ]] && echo Adding subnet to Plex Whitelist... && mkdir -p $VOLDIR/plex/Plex\ Media\ Server/ && \
|
||||||
exec docker-compose -p media -f $VOLDIR/launcher/media-compose.yml up -d
|
echo -e "<?xml version="1.0" encoding="utf-8"?>\n<Preferences allowedNetworks="$(ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1' | grep -v '172.*')/255.255.0.0" />" > $VOLDIR/plex/Plex\ Media\ Server/Preferences.xml && chown -R 787:787 $VOLDIR/plex
|
||||||
|
|
||||||
|
[[ ! -a ./docker-compose.yml ]] && echo "Downloading Docker Compose config.." && curl -sSL https://raw.githubusercontent.com/Adam-Ant/media-server-in-a-box/proxy/docker-compose.yml > ./docker-compose.yml
|
||||||
|
[[ ! -a $VOLDIR/launcher/nginx.cfg ]] && echo "Downloading nginx.cfg..." && curl -sSL https://raw.githubusercontent.com/Adam-Ant/media-server-in-a-box/proxy/nginx.cfg > $VOLDIR/launcher/nginx.cfg
|
||||||
|
|
||||||
|
echo "#####################################"
|
||||||
|
echo "# Config and directory struture OK! #"
|
||||||
|
echo "#####################################"
|
||||||
|
echo
|
||||||
|
echo "Run docker-compose up -d to start the containers..."
|
||||||
|
Loading…
Reference in New Issue
Block a user