Compare commits
2 Commits
f704098473
..
nginx
| Author | SHA1 | Date | |
|---|---|---|---|
| 669ea6a41b | |||
| 8057cdb44d |
+1
-2
@@ -1,4 +1,3 @@
|
|||||||
.vscode
|
.vscode
|
||||||
__pycache__
|
__pycache__
|
||||||
test.mp4
|
test.mp4
|
||||||
env
|
|
||||||
+3
-8
@@ -13,14 +13,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{$CADDY_SITE:":80"} {
|
:80 {
|
||||||
|
#nl.u2b.cx u2b.cx {
|
||||||
log
|
log
|
||||||
tls {
|
|
||||||
dns porkbun {
|
|
||||||
api_key {env.PORKBUN_API_KEY}
|
|
||||||
api_secret_key {env.PORKBUN_API_SECRET}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
handle_path /proxy/* {
|
handle_path /proxy/* {
|
||||||
@gv path_regexp gvurl ^\/([a-z0-9-]+\.googlevideo\.com)
|
@gv path_regexp gvurl ^\/([a-z0-9-]+\.googlevideo\.com)
|
||||||
handle @gv {
|
handle @gv {
|
||||||
@@ -50,7 +45,7 @@ Disallow: /
|
|||||||
@notget not method GET
|
@notget not method GET
|
||||||
respond @notget 403
|
respond @notget 403
|
||||||
|
|
||||||
reverse_proxy http://127.0.0.1:8080
|
reverse_proxy http://app:8080
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-3
@@ -1,6 +1,4 @@
|
|||||||
FROM caddy:2.6-builder AS builder
|
FROM caddy:2.6-builder AS builder
|
||||||
RUN xcaddy build \
|
RUN xcaddy build --with github.com/caddyserver/transform-encoder
|
||||||
--with github.com/caddyserver/transform-encoder \
|
|
||||||
--with github.com/caddy-dns/porkbun
|
|
||||||
FROM caddy:2.6
|
FROM caddy:2.6
|
||||||
COPY --from=builder /usr/bin/caddy /usr/bin/caddy
|
COPY --from=builder /usr/bin/caddy /usr/bin/caddy
|
||||||
+18
-9
@@ -8,20 +8,29 @@ services:
|
|||||||
- ./:/app/
|
- ./:/app/
|
||||||
working_dir: /app/
|
working_dir: /app/
|
||||||
environment:
|
environment:
|
||||||
- ADDRESS=127.0.0.1
|
|
||||||
- PORT=8080
|
- PORT=8080
|
||||||
- PROXY=/proxy/
|
- PROXY=/proxy/
|
||||||
network_mode: host
|
|
||||||
command: python server.py
|
command: python server.py
|
||||||
caddy:
|
# caddy:
|
||||||
build: caddy
|
# image: caddy:2.6
|
||||||
|
# restart: always
|
||||||
|
# ports:
|
||||||
|
# - "80:80"
|
||||||
|
# - "443:443"
|
||||||
|
# - "443:443/udp"
|
||||||
|
# volumes:
|
||||||
|
# - ./Caddyfile:/etc/caddy/Caddyfile
|
||||||
|
# - caddy_data:/data
|
||||||
|
# - caddy_config:/config
|
||||||
|
nginx:
|
||||||
|
image: nginx:1.25
|
||||||
restart: always
|
restart: always
|
||||||
network_mode: host
|
|
||||||
volumes:
|
volumes:
|
||||||
- ./caddy/Caddyfile:/etc/caddy/Caddyfile
|
- ./nginx.conf:/etc/nginx/nginx.conf:ro
|
||||||
- caddy_data:/data
|
ports:
|
||||||
- caddy_config:/config
|
- "80:80"
|
||||||
env_file: env
|
- "443:443"
|
||||||
|
- "443:443/udp"
|
||||||
volumes:
|
volumes:
|
||||||
caddy_data:
|
caddy_data:
|
||||||
caddy_config:
|
caddy_config:
|
||||||
+56
@@ -0,0 +1,56 @@
|
|||||||
|
user nginx;
|
||||||
|
worker_processes auto;
|
||||||
|
error_log /var/log/nginx/error.log notice;
|
||||||
|
pid /var/run/nginx.pid;
|
||||||
|
events {
|
||||||
|
worker_connections 1024;
|
||||||
|
}
|
||||||
|
|
||||||
|
http {
|
||||||
|
log_format main '$time_local $remote_addr "$request" $status "$http_user_agent"';
|
||||||
|
access_log /var/log/nginx/access.log main;
|
||||||
|
resolver 8.8.8.8 ipv6=off;#until I can get ipv6 on the new host
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
|
||||||
|
location /proxy/ {
|
||||||
|
limit_except GET { deny all; }
|
||||||
|
location ~^/proxy/([a-z0-9-]+)\.googlevideo\.com/videoplayback {
|
||||||
|
#return 200 "$uri\n\n$request_uri\n\n$query_string\n\nhttps://$1/$2";
|
||||||
|
proxy_pass https://$1.googlevideo.com/videoplayback?$query_string;
|
||||||
|
#proxy_redirect ~https://([a-z0-9-]+).googlevideo.com/ /proxy/$1.googlevideo.com/;
|
||||||
|
proxy_redirect https:// /proxy/;
|
||||||
|
}
|
||||||
|
return 403;
|
||||||
|
}
|
||||||
|
|
||||||
|
location = / {
|
||||||
|
return 301 https://www.u2b.cx/;
|
||||||
|
}
|
||||||
|
location = /favicon.ico {
|
||||||
|
return 404;
|
||||||
|
}
|
||||||
|
location /. {
|
||||||
|
return 403;
|
||||||
|
}
|
||||||
|
location = /robots.txt {
|
||||||
|
add_header Content-Type text/plain;
|
||||||
|
return 200 "User-agent: *\nDisallow: /\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request_method != GET) {
|
||||||
|
return 403;
|
||||||
|
}
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Connection "";
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Host $host;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
proxy_pass http://app:8080;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,10 +26,10 @@ class Handler(BaseHTTPRequestHandler):
|
|||||||
def address_string(self):
|
def address_string(self):
|
||||||
return getattr(self, 'headers', {}).get('X-Forwarded-For', '').split(',')[0] or self.client_address[0]
|
return getattr(self, 'headers', {}).get('X-Forwarded-For', '').split(',')[0] or self.client_address[0]
|
||||||
|
|
||||||
#def is_pc_vrchat(self):
|
def is_pc_vrchat(self):
|
||||||
# ua = self.headers.get('User-Agent', '')
|
ua = self.headers.get('User-Agent', '')
|
||||||
# ae = self.headers.get('Accept-Encoding', '')
|
ae = self.headers.get('Accept-Encoding', '')
|
||||||
# return ua.startswith("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/") and ua.endswith(" Safari/537.36") and ae == "identity"
|
return ua.startswith("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/") and ua.endswith(" Safari/537.36") and ae == "identity"
|
||||||
|
|
||||||
def send_error(self, code, message=""):
|
def send_error(self, code, message=""):
|
||||||
body = bytes(message, "utf-8")
|
body = bytes(message, "utf-8")
|
||||||
@@ -48,11 +48,11 @@ class Handler(BaseHTTPRequestHandler):
|
|||||||
path = unquote(self.path)
|
path = unquote(self.path)
|
||||||
match = re.match("\/(?:id\/|(?:https?:\/\/)?(?:(?:www\.|music\.|m\.)?youtube\.com\/(?:watch\?v=|shorts\/)|youtu\.be\/))([A-Za-z0-9_-]{11})", path)
|
match = re.match("\/(?:id\/|(?:https?:\/\/)?(?:(?:www\.|music\.|m\.)?youtube\.com\/(?:watch\?v=|shorts\/)|youtu\.be\/))([A-Za-z0-9_-]{11})", path)
|
||||||
if match:
|
if match:
|
||||||
#if self.is_pc_vrchat():
|
if self.is_pc_vrchat():
|
||||||
# self.send_response(302)
|
self.send_response(302)
|
||||||
# self.send_header("Location", "https://www.youtube.com/watch?v=" + match[1])
|
self.send_header("Location", "https://www.youtube.com/watch?v=" + match[1])
|
||||||
# self.end_headers()
|
self.end_headers()
|
||||||
# return
|
return
|
||||||
query = match[1]
|
query = match[1]
|
||||||
else:
|
else:
|
||||||
query = "ytsearch:" + path[1:]
|
query = "ytsearch:" + path[1:]
|
||||||
@@ -70,7 +70,7 @@ class Handler(BaseHTTPRequestHandler):
|
|||||||
'event': Event(),
|
'event': Event(),
|
||||||
'expire': datetime.now() + timedelta(hours=5)
|
'expire': datetime.now() + timedelta(hours=5)
|
||||||
}
|
}
|
||||||
with YoutubeDL({'extractor_args': {'youtube': {'skip': ['dash', 'hls']}}}) as ydl:
|
with YoutubeDL() as ydl:
|
||||||
info = ydl.extract_info(query, download=False)
|
info = ydl.extract_info(query, download=False)
|
||||||
|
|
||||||
selection = info
|
selection = info
|
||||||
@@ -103,12 +103,12 @@ class Handler(BaseHTTPRequestHandler):
|
|||||||
elif 'url' not in ctx:
|
elif 'url' not in ctx:
|
||||||
ctx['event'].wait(60)
|
ctx['event'].wait(60)
|
||||||
|
|
||||||
#if self.is_pc_vrchat():
|
if self.is_pc_vrchat():
|
||||||
# if ctx.get('id'):
|
if ctx.get('id'):
|
||||||
# self.send_response(302)
|
self.send_response(302)
|
||||||
# self.send_header("Location", "https://www.youtube.com/watch?v=" + ctx['id'])
|
self.send_header("Location", "https://www.youtube.com/watch?v=" + ctx['id'])
|
||||||
# self.end_headers()
|
self.end_headers()
|
||||||
# return
|
return
|
||||||
|
|
||||||
if not ctx.get('url'):
|
if not ctx.get('url'):
|
||||||
if 'exception' in ctx:
|
if 'exception' in ctx:
|
||||||
|
|||||||
Reference in New Issue
Block a user