Skip to content

Instantly share code, notes, and snippets.

@return0927
Last active October 8, 2023 06:35
Show Gist options
  • Save return0927/f093bbf6541ea930967b74bcff2b9f76 to your computer and use it in GitHub Desktop.
Save return0927/f093bbf6541ea930967b74bcff2b9f76 to your computer and use it in GitHub Desktop.
twitch-proxy
version: "3"
services:
web:
build: ./web
ports:
- 20001:3000
hls-proxy:
build: ./hls-proxy
ports:
- 20002:80
const input = document.querySelector('input');
const button = document.querySelector('button');
const p = document.querySelector('p');
chrome
.declarativeNetRequest
.getDynamicRules()
.then((rules) => {
if (rules.length > 0) {
p.textContent = `프록시 서버로 우회중...`;
}
});
function updateRules() {
const address = input.value;
if (address === '') {
p.textContent = '프록시 서버가 없습니다. 주소를 입력해 주세요...';
chrome.declarativeNetRequest.updateDynamicRules({ removeRuleIds: [1, 2, 3] });
return;
}
p.textContent = `${input.value} 프록시 서버로 우회중...`;
chrome.declarativeNetRequest.updateDynamicRules({
addRules: [
{
"id": 1,
"priority": 1,
"action": {
"type": "redirect",
"redirect": {
"regexSubstitution": "https://" + address + "/proxy/usher.ttvnw.net/\\1"
}
},
"condition": {
"regexFilter": "https://usher.ttvnw.net/(.*)",
"resourceTypes": ["xmlhttprequest"]
}
},
{
"id": 2,
"priority": 1,
"action": {
"type": "redirect",
"redirect": {
"regexSubstitution": "https://" + address + "/proxy/video-weaver.\\1/\\2"
}
},
"condition": {
"regexFilter": "https://video-weaver.(.*)/(.*)",
"resourceTypes": ["xmlhttprequest"]
}
},
{
"id": 3,
"priority": 1,
"action": {
"type": "redirect",
"redirect": {
"regexSubstitution": "https://" + address + "/proxy/video-edge-\\1/\\2"
}
},
"condition": {
"regexFilter": "https://video-edge-(.*)/(.*)",
"resourceTypes": ["xmlhttprequest"]
}
}
],
removeRuleIds: [1, 2, 3]
});
}
button.addEventListener('click', updateRules);
server {
listen 80;
server_name twitch.go9.ma;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
server_name twitch.go9.ma;
ssl_certificate "/etc/letsencrypt/live/go9.ma/fullchain.pem";
ssl_certificate_key "/etc/letsencrypt/live/go9.ma/privkey.pem";
include include.d/ssl.conf;
#access_log /var/log/nginx/go9.ma/access.log;
#error_log /var/log/nginx/go9.ma/error.log;
#client_max_body_sze 1G;
location / {
proxy_pass_header Server;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_pass http://127.0.0.1:20002/;
}
location /proxy {
rewrite ^/proxy/(.*) /$1 break;
proxy_pass http://127.0.0.1:20001/;
proxy_pass_header Server;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment