Use docker to deploy emby and v2ray on your VPS

Use docker to deploy emby and v2ray on your VPS

Work in progress…

Update 2020/05/11 Caddy V2 has been released! I will upgrade the Caddyfile to v2 format(JSON).

Some useful bash script #

  1. BBR plus https://github.com/chiakge/Linux-NetSpeed
  2. Virtual memory https://www.moerats.com/usr/shell/swap.sh

Cloudflare CNAME setup #

Go to https://cdn.moeelf.com/ Login using cloudflare credentials

Set up a CNAME or A entry to origin server, then add the cloudflare *.cdn.cloudflare.net CNAME to your DNS service provider

You can enable CDN as well

Install Caddy #

Set up Caddyfile #

touch /etc/caddy/Caddyfile
v.lightsailjp.zb8.stream {
  gzip
  tls {
      dns cloudflare
  }
  log /var/log/caddy/caddy.v2ray.log
  proxy /leet 127.0.0.1:13337 {
    websocket
    header_upstream -Origin
  }
}

t.lightsailjp.zb8.stream {
  gzip
  tls {
      dns cloudflare
  }
  log /var/log/caddy/caddy.trojan.log
  proxy / https://baidu.com
  proxy /leet 127.0.0.1:13338 {
    websocket
    header_upstream -Origin
  }
}


embyjp.zb8.stream {
  gzip
  tls {
      dns cloudflare
        }
  log /var/log/caddy/caddy.emby.log
  proxy / 127.0.0.1:8096 {
   header_upstream -Origin
  websocket
        }
}

Set up logs #

mkdir /var/log/caddy

Install Caddy as a systemd service #

Download https://raw.githubusercontent.com/caddyserver/caddy/master/dist/init/linux-systemd/caddy.service to /etc/systemd/systemd

Use rclone to mount google drive team drive #

curl https://rclone.org/install.sh | sudo bash

Mount rclone drive #

mkdir ~/rclone/00drive

rclone mount 00drive: /home/ubuntu/rclone/00drive/  --buffer-size 1G --vfs-read-chunk-size 256M --vfs-read-chunk-size-limit 2G  --allow-non-empty --allow-other   --dir-cache-time 12h > /dev/null 2>&1 &

If working, add the line above to /etc/crontab:

@reboot [User] rclone mount 00drive: /home/ubuntu/rclone/00drive/ –buffer-size 1G –vfs-read-chunk-size 256M –vfs-read-chunk-size-limit 2G –allow-non-empty –allow-other –dir-cache-time 12h > /dev/null 2>&1 &

Install emby #

mkdir ~/emby/ mkdir ~/emby/config docker run –name=emby -d -v /home/ubuntu/emby/config:/config -v /home/ubuntu/rclone:/mymedia -p 8096:8096 -p 8920:8920 -e UID=1000 -e GID=100 -e GIDLIST=100 –restart unless-stopped emby/embyserver:latest

Install v2ray #

mkdir /etc/v2ray
touch /etc/v2ray/config.json
docker run -d -p 13337:13337 --name v2tay --restart=always -v /root/caddy/v2ray:/etc/v2ray teddysun/v2ray