From 08dd1273c60732f32a7eac2dcdd18b45c0535fa2 Mon Sep 17 00:00:00 2001 From: Opnxng Date: Mon, 20 Nov 2023 02:43:41 +0800 Subject: [PATCH] Added Cloudtube + Removed 4get --- config-tasks/cloudtube.yaml | 51 +++++++++++++++++++++++++++++ templates/compose/4get.yaml.j2 | 2 +- templates/compose/cloudtube.yaml.j2 | 46 ++++++++++++++++++++++++++ templates/conf/Caddyfile.j2 | 50 ++++++++++++++-------------- templates/conf/config.js.j2 | 18 ++++++++++ templates/conf/config.yml.j2 | 2 +- templates/conf/configuration.py.j2 | 17 ++++++++++ vars/services.yaml | 20 +++-------- 8 files changed, 163 insertions(+), 43 deletions(-) create mode 100644 config-tasks/cloudtube.yaml create mode 100644 templates/compose/cloudtube.yaml.j2 create mode 100644 templates/conf/config.js.j2 create mode 100644 templates/conf/configuration.py.j2 diff --git a/config-tasks/cloudtube.yaml b/config-tasks/cloudtube.yaml new file mode 100644 index 0000000..c3f61e3 --- /dev/null +++ b/config-tasks/cloudtube.yaml @@ -0,0 +1,51 @@ + - name: Set up cloudtube config.js + template: + src: "conf/config.js.j2" + dest: "{{ docker_dir }}/cloudtube/config.js" + owner: 1000 + group: 1000 + mode: 0755 + + - name: Set up newleaf + template: + src: "conf/configuration.py.j2" + dest: "{{ docker_dir }}/cloudtube/configuration.py" + owner: 1000 + group: 1000 + mode: 0755 + + - name: Install packages for smart-ipv6-rotator + apt: + name: + - python3-pyroute2 + - python3-requests + state: latest + install_recommends: false + + - name: Clone smart-ipv6-rotator + ansible.builtin.git: + repo: https://github.com/iv-org/smart-ipv6-rotator.git + dest: "{{ docker_dir }}/cloudtube/smart-ipv6-rotator" + single_branch: yes + version: master + +# - name: vultr cron +# cron: +# name: "Rotating IPv6 address on boot" +# special_time: "reboot" +# job: 'sleep 30s && python3 {{ docker_dir }}/cloudtube/smart-ipv6-rotator/smart-ipv6-rotator.py run --ipv6range=2001:19f0:4400:2e62::/64 && curl -H prio:low -d "Rotate IPv6 address successful" https://ntfy.opnxng.com/cron || curl -H tags:warning -H prio:high -d "Rotate IPv6 address failed!" https://ntfy.opnxng.com/cron;' +# user: root +# become: true +# when: +# - inventory_hostname == 'vultr' +# +# - name: vultr cron +# cron: +# name: "Rotating IPv6 address twice a day" +# minute: "0" +# hour: "*/12" +# job: 'python3 {{ docker_dir }}/cloudtube/smart-ipv6-rotator/smart-ipv6-rotator.py run --ipv6range=2001:19f0:4400:2e62::/64 && curl -H prio:low -d "Rotate IPv6 address successful" https://ntfy.opnxng.com/cron || curl -H tags:warning -H prio:high -d "Rotate IPv6 address failed!" https://ntfy.opnxng.com/cron;' +# user: root +# become: true +# when: +# - inventory_hostname == 'vultr' diff --git a/templates/compose/4get.yaml.j2 b/templates/compose/4get.yaml.j2 index ff3b3bf..ae930fb 100644 --- a/templates/compose/4get.yaml.j2 +++ b/templates/compose/4get.yaml.j2 @@ -16,7 +16,7 @@ services: - FOURGET_SERVER_ADMIN_EMAIL=opnxng@tuta.io volumes: - {{ docker_dir }}/4get/config.php:/data/config.php - restart: unless-stopped + #restart: unless-stopped ports: - '8907:80' networks: diff --git a/templates/compose/cloudtube.yaml.j2 b/templates/compose/cloudtube.yaml.j2 new file mode 100644 index 0000000..b4cdcfe --- /dev/null +++ b/templates/compose/cloudtube.yaml.j2 @@ -0,0 +1,46 @@ +# {{ ansible_managed }} +version: "3.4" + +services: + cloudtube: + image: abeltramo/cloudtube:latest + container_name: cloudtube + security_opt: + - no-new-privileges + cap_drop: + - ALL + environment: + - PUID=1000 + - PGID=1000 + - TZ=Asia/Singapore + ports: + - 8911:10412 + depends_on: + - newleaf + restart: unless-stopped + volumes: + - {{ docker_dir }}/cloudtube/db:/workdir/db + - {{ docker_dir }}/cloudtube/config.js:/workdir/config/config.js #instance should be "http://newleaf:3000" + networks: + - cloudtube + + newleaf: + image: abeltramo/newleaf:latest + container_name: newleaf + security_opt: + - no-new-privileges + cap_drop: + - ALL + environment: + - PUID=1000 + - PGID=1000 + - TZ=Asia/Singapore + restart: unless-stopped + volumes: + - {{ docker_dir }}/cloudtube/configuration.py:/workdir/configuration.py #set e.g. website_origin = "https://tube.domain.tld" and bind_port = 3000 + networks: + - cloudtube + +networks: + cloudtube: + name: cloudtube diff --git a/templates/conf/Caddyfile.j2 b/templates/conf/Caddyfile.j2 index 9de9d81..6023a48 100755 --- a/templates/conf/Caddyfile.j2 +++ b/templates/conf/Caddyfile.j2 @@ -544,29 +544,29 @@ } } - @4g host 4g.{$HOSTNAME} - handle @4g { - encode zstd gzip - @notstatic { - not path /static/* /android-chrome* /favicon* /robots.txt /banner/* /site.webmanifest - } - rate_limit @notstatic {remote.ip} 2r/s 60000 500 - rate_limit @notstatic {remote.ip} 45r/m 300000 500 - reverse_proxy { - to {{ oracle1_private_ip }}:8907 - to {{ oracle2_private_ip }}:8907 - to {{ oracle3_private_ip }}:8907 - to {{ oracle4_private_ip }}:8907 - lb_policy ip_hash - lb_try_duration 5s - lb_try_interval 1s - fail_duration 30s - max_fails 3 - } - header { - X-Robots-Tag "noindex, noimageindex, nosnippet, notranslate, noarchive, nofollow" - } - } +# @4g host 4g.{$HOSTNAME} +# handle @4g { +# encode zstd gzip +# @notstatic { +# not path /static/* /android-chrome* /favicon* /robots.txt /banner/* /site.webmanifest +# } +# rate_limit @notstatic {remote.ip} 2r/s 60000 500 +# rate_limit @notstatic {remote.ip} 45r/m 300000 500 +# reverse_proxy { +# to {{ oracle1_private_ip }}:8907 +# to {{ oracle2_private_ip }}:8907 +# to {{ oracle3_private_ip }}:8907 +# to {{ oracle4_private_ip }}:8907 +# lb_policy ip_hash +# lb_try_duration 5s +# lb_try_interval 1s +# fail_duration 30s +# max_fails 3 +# } +# header { +# X-Robots-Tag "noindex, noimageindex, nosnippet, notranslate, noarchive, nofollow" +# } +# } @ig host ig.{$HOSTNAME} handle @ig { @@ -615,8 +615,8 @@ } } - @y host y.{$HOSTNAME} - handle @y { + @yt host yt.{$HOSTNAME} + handle @yt { encode zstd gzip reverse_proxy {{ vultr_private_ip }}:8911 header { diff --git a/templates/conf/config.js.j2 b/templates/conf/config.js.j2 new file mode 100644 index 0000000..1842794 --- /dev/null +++ b/templates/conf/config.js.j2 @@ -0,0 +1,18 @@ +module.exports = { +/* + Copy this file to `config.js`, and add options here. + They'll override the options from `utils/constants.js`. + For example, the next block changes the default instance. +*/ + user_settings: { + instance: { + default: "http://newleaf:3000" + } + }, + /* + If cloudtube and Newleaf is not in same docker-network, you need to also set local_instance_origin. + */ + server_setup: { + local_instance_origin: "http://newleaf:3000" + } +} diff --git a/templates/conf/config.yml.j2 b/templates/conf/config.yml.j2 index f212ae6..2bba360 100644 --- a/templates/conf/config.yml.j2 +++ b/templates/conf/config.yml.j2 @@ -423,7 +423,7 @@ jobs: ## Accepted values: any string. HTML is accepted. ## Default: ## -#banner: +banner:

Please use another instance if you wish to proxy videos.

## ## Subscribe to channels using PubSubHub (Google PubSubHubbub service). diff --git a/templates/conf/configuration.py.j2 b/templates/conf/configuration.py.j2 new file mode 100644 index 0000000..d0b014c --- /dev/null +++ b/templates/conf/configuration.py.j2 @@ -0,0 +1,17 @@ +# ============================== +# You MUST set these settings. +# ============================== + +# A URL that this site can be accessed on. Do not include a trailing slash. +website_origin = "http://newleaf:3000" + + +# ============================== +# These settings are optional. +# ============================== + +# The address of the interface to bind to. +#bind_host = "0.0.0.0" + +# The port to bind to. +#bind_port = 3000 \ No newline at end of file diff --git a/vars/services.yaml b/vars/services.yaml index adecc78..558c6a1 100644 --- a/vars/services.yaml +++ b/vars/services.yaml @@ -1,23 +1,19 @@ config: - oracle4: - - caddy + vultr: + - cloudtube -compose: - oracle4: - - caddy # ---------------------------------------------------------------------------------------------------- deployed-compose: vultr: - - invidious + - cloudtube #################### - teddit - libreddit - imgin - rat-aint-tieba - watchtower - - 4get - socks5 oracle1: - send @@ -41,7 +37,6 @@ deployed-compose: - libremdb - binternet - watchtower - - 4get - socks5 oracle2: - firefox @@ -65,7 +60,6 @@ deployed-compose: - libremdb - binternet - watchtower - - 4get - socks5 oracle3: - breezewiki @@ -92,7 +86,6 @@ deployed-compose: - libremdb - binternet - watchtower - - 4get - socks5 oracle4: - caddy @@ -119,21 +112,18 @@ deployed-compose: - libremdb - binternet - watchtower - - 4get - socks5 # ---------------------------------------------------------------------------------------------------- deployed-config: vultr: - - invidious + - cloudtube oracle1: - - 4get - anonymousoverflow - scribe oracle2: - firefox - - 4get - anonymousoverflow - scribe oracle3: @@ -142,7 +132,6 @@ deployed-config: - gitea-netrc - runner - breezewiki - - 4get - anonymousoverflow - scribe oracle4: @@ -150,6 +139,5 @@ deployed-config: - nitter - paulgo - caddy - - 4get - anonymousoverflow - scribe