Skip to content
This repository was archived by the owner on Feb 17, 2024. It is now read-only.

Commit 203c0eb

Browse files
committed
add new piped (hopefully faster) instance
1 parent 82bff5b commit 203c0eb

11 files changed

+395
-1
lines changed

.github/workflows/piped.yml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: deploy-piped
2+
3+
on:
4+
push:
5+
paths:
6+
- '.github/workflows/piped.yml'
7+
- 'piped/**'
8+
branches: [main]
9+
workflow_dispatch:
10+
11+
jobs:
12+
deploy:
13+
runs-on: ubuntu-latest
14+
environment:
15+
name: piped
16+
url: https://piped.aosus.link
17+
steps:
18+
- name: checkout
19+
uses: actions/checkout@v3
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Tailscale
24+
uses: tailscale/github-action@ce41a99162202a647a4b24c30c558a567b926709
25+
with:
26+
authkey: ${{ secrets.TAILSCALE_AUTHKEY }}
27+
hostname: Github-actions
28+
version: ${{ vars.TAILSCALE_VERSION }}
29+
30+
- name: Add secrets to config files
31+
env:
32+
POSTGRES_PASSWORD: ${{ secrets.piped_postgres_password }}
33+
run: |
34+
sed -i "s/(piped_postgres_password)/$POSTGRES_PASSWORD/g" $GITHUB_WORKSPACE/piped/config.properties
35+
36+
- name: Start Deployment
37+
uses: FarisZR/docker-compose-gitops-action@v1
38+
env:
39+
POSTGRES_PASSWORD: ${{ secrets.piped_postgres_password }}
40+
with:
41+
remote_docker_host: ${{ secrets.server_address }}
42+
tailscale_ssh: true # no need for manual private and public keys
43+
upload_directory: true # upload docker directory
44+
docker_compose_directory: piped # directory to upload
45+
compose_file_path: piped/docker-compose.yml
46+
args: -p piped up -d --remove-orphans

caddy/configs/piped.caddy

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
(piped-global) {
2+
header {
3+
# disable FLoC tracking
4+
Permissions-Policy interest-cohort=()
5+
6+
# enable HSTS
7+
Strict-Transport-Security max-age=31536000;
8+
9+
# keep referrer data off
10+
Referrer-Policy no-referrer
11+
}
12+
}
13+
14+
piped.aosus.link {
15+
# aosus settings
16+
respond /robots.txt 200 {
17+
body "User-agent: *
18+
Disallow: /"
19+
}
20+
header {
21+
X-Robots-Tag "noindex, noarchive, nofollow, nosnippet"
22+
X-XSS-Protection "1; mode=block"
23+
}
24+
# end aosus settings
25+
reverse_proxy pipedfrontend:80
26+
import piped-global
27+
encode zstd gzip
28+
}
29+
30+
api.piped.aosus.link {
31+
# aosus settings
32+
respond /robots.txt 200 {
33+
body "User-agent: *
34+
Disallow: /"
35+
}
36+
header {
37+
X-Robots-Tag "noindex, noarchive, nofollow, nosnippet"
38+
X-XSS-Protection "1; mode=block"
39+
}
40+
# end aosus settings
41+
reverse_proxy piped-nginx:80
42+
import piped-global
43+
encode zstd gzip
44+
}
45+
46+
proxy.piped.aosus.link {
47+
@ytproxy path /videoplayback* /api/v4/* /api/manifest/*
48+
import piped-global
49+
# aosus settings
50+
respond /robots.txt 200 {
51+
body "User-agent: *
52+
Disallow: /"
53+
}
54+
header {
55+
X-Robots-Tag "noindex, noarchive, nofollow, nosnippet"
56+
X-XSS-Protection "1; mode=block"
57+
}
58+
# end aosus settings
59+
route {
60+
header @ytproxy {
61+
Cache-Control private always
62+
}
63+
64+
header / {
65+
Cache-Control "public, max-age=604800"
66+
}
67+
68+
reverse_proxy unix//var/run/ytproxy/actix.sock {
69+
header_up -CF-Connecting-IP
70+
header_up -X-Forwarded-For
71+
header_down -etag
72+
header_down -alt-svc
73+
}
74+
}
75+
encode zstd gzip
76+
}

caddy/docker-compose.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ services:
2424
- /home/aosus/caddy/configs:/etc/caddy/configs:ro
2525
- data:/data
2626
- config:/config
27+
- piped-proxy:/var/run/ytproxy
2728
networks:
2829
web:
2930
discourse:
@@ -33,4 +34,6 @@ configs:
3334

3435
volumes:
3536
data:
36-
config:
37+
config:
38+
piped_piped-proxy:
39+
external: true

piped/config.properties

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# The port to Listen on.
2+
PORT: 8080
3+
4+
# The number of workers to use for the server
5+
HTTP_WORKERS: 8
6+
7+
# Proxy
8+
PROXY_PART: https://proxy.piped.aosus.link
9+
10+
# Outgoing HTTP Proxy - eg: 127.0.0.1:8118
11+
#HTTP_PROXY: 127.0.0.1:8118
12+
13+
# Captcha Parameters
14+
#CAPTCHA_BASE_URL: https://api.capmonster.cloud/
15+
#CAPTCHA_API_KEY: INSERT_HERE
16+
17+
# Public API URL
18+
API_URL: https://api.piped.aosus.link
19+
20+
# Public Frontend URL
21+
FRONTEND_URL: https://piped.aosus.link
22+
23+
# Enable haveibeenpwned compromised password API
24+
COMPROMISED_PASSWORD_CHECK: true
25+
26+
# Disable Registration
27+
DISABLE_REGISTRATION: false
28+
29+
# Feed Retention Time in Days
30+
FEED_RETENTION: 30
31+
32+
# Hibernate properties
33+
hibernate.connection.url: jdbc:postgresql://postgres:5432/piped
34+
hibernate.connection.driver_class: org.postgresql.Driver
35+
hibernate.dialect: org.hibernate.dialect.PostgreSQLDialect
36+
hibernate.connection.username: piped
37+
hibernate.connection.password: (piped_postgres_password)
38+
39+
# Frontend configuration
40+
frontend.statusPageUrl:https://status.aosus.org
41+
frontend.donationUrl:https://opencollective.com/aosus

piped/config/Caddyfile

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
(global) {
2+
header {
3+
# disable FLoC tracking
4+
Permissions-Policy interest-cohort=()
5+
6+
# enable HSTS
7+
Strict-Transport-Security max-age=31536000;
8+
9+
# keep referrer data off
10+
Referrer-Policy no-referrer
11+
12+
# prevent for appearing in search engine for private instances (option)
13+
#X-Robots-Tag noindex
14+
}
15+
}
16+
17+
piped.aosus.org {
18+
reverse_proxy pipedfrontend:80
19+
import global
20+
}
21+
22+
api.piped.aosus.org {
23+
reverse_proxy nginx:80
24+
import global
25+
}
26+
27+
proxy.piped.aosus.org {
28+
@ytproxy path /videoplayback* /api/v4/* /api/manifest/*
29+
import global
30+
31+
route {
32+
header @ytproxy {
33+
Cache-Control private always
34+
}
35+
36+
header / {
37+
Cache-Control "public, max-age=604800"
38+
}
39+
40+
reverse_proxy unix//var/run/ytproxy/actix.sock {
41+
header_up -CF-Connecting-IP
42+
header_up -X-Forwarded-For
43+
header_down -etag
44+
header_down -alt-svc
45+
}
46+
}
47+
}

piped/config/nginx.conf

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
user root;
2+
worker_processes auto;
3+
4+
error_log /var/log/nginx/error.log notice;
5+
pid /var/run/nginx.pid;
6+
7+
8+
events {
9+
worker_connections 1024;
10+
}
11+
12+
13+
http {
14+
include /etc/nginx/mime.types;
15+
default_type application/octet-stream;
16+
17+
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
18+
'$status $body_bytes_sent "$http_referer" '
19+
'"$http_user_agent" "$http_x_forwarded_for"';
20+
21+
access_log /var/log/nginx/access.log main;
22+
23+
sendfile on;
24+
tcp_nodelay on;
25+
26+
keepalive_timeout 65;
27+
28+
resolver 127.0.0.11 ipv6=off valid=10s;
29+
30+
include /etc/nginx/conf.d/*.conf;
31+
}

piped/config/pipedapi.conf

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
proxy_cache_path /tmp/pipedapi_cache levels=1:2 keys_zone=pipedapi:4m max_size=2g inactive=60m use_temp_path=off;
2+
3+
server {
4+
listen 80;
5+
server_name api.piped.aosus.link;
6+
7+
set $backend "http://piped:8080";
8+
9+
location / {
10+
proxy_cache pipedapi;
11+
proxy_pass $backend;
12+
proxy_http_version 1.1;
13+
proxy_set_header Connection "keep-alive";
14+
}
15+
}

piped/config/pipedfrontend.conf

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
server {
2+
listen 80;
3+
server_name piped.aosus.link;
4+
5+
set $backend "http://pipedfrontend:80";
6+
7+
location / {
8+
proxy_pass $backend;
9+
proxy_http_version 1.1;
10+
proxy_set_header Connection "keep-alive";
11+
}
12+
}

piped/config/pipedproxy.conf

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
server {
2+
listen 80;
3+
server_name proxy.piped.aosus.link;
4+
5+
location ~ (/videoplayback|/api/v4/|/api/manifest/) {
6+
include snippets/ytproxy.conf;
7+
add_header Cache-Control private always;
8+
}
9+
10+
location / {
11+
include snippets/ytproxy.conf;
12+
add_header Cache-Control "public, max-age=604800";
13+
}
14+
}

piped/config/ytproxy.conf

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
proxy_buffering on;
2+
proxy_buffers 1024 16k;
3+
proxy_set_header X-Forwarded-For "";
4+
proxy_set_header CF-Connecting-IP "";
5+
proxy_hide_header "alt-svc";
6+
sendfile on;
7+
sendfile_max_chunk 512k;
8+
tcp_nopush on;
9+
aio threads=default;
10+
aio_write on;
11+
directio 16m;
12+
proxy_hide_header Cache-Control;
13+
proxy_hide_header etag;
14+
proxy_http_version 1.1;
15+
proxy_set_header Connection keep-alive;
16+
proxy_max_temp_file_size 32m;
17+
access_log off;
18+
proxy_pass http://unix:/var/run/ytproxy/actix.sock;

0 commit comments

Comments
 (0)