github文件地址:
https://github.com/zizifn/edgetunnel/blob/main/src/worker-vless.js
本地拷贝件地址:
worker-vless.js 继续阅读
github文件地址:
https://github.com/zizifn/edgetunnel/blob/main/src/worker-vless.js
本地拷贝件地址:
worker-vless.js 继续阅读
操作方法:
1、使用 root 权限运行下面代码
uname -r //内核版本高于 4.9 就行
2、开启BBR
echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf
cloudflare申请一个证书,通过SSH scp命令上传到服务器,然后再开启HTTPS,省略了acme.sh申请证书的步骤。
x-ui面板安装命令:
bash <(curl -Ls https://raw.githubusercontent.com/vaxilu/x-ui/master/install.sh)
安装完成后开启HTTPS,然后创建节点。端口选择时,如果使用了cloudflare,端口也需要选择cloudflare能识别的。Cloudflare 支持的 HTTPs 端口为: 443 2053 2083 2087 2096 8443; 继续阅读
前言:
V2Ray 官网:https://www.v2ray.com
V2Ray 是一个于 Shadowsocks 之后非常好用的代理软件,但是由于 V2Ray 的配置略复杂,GUI 客户端不完善,所以 V2Ray 并没有像 Shadowsocks 在科学上网人群之中那么流行。 不过我想,像我这种小小白萌新,更需要的是一个好用的一键安装脚本…… 所以,此脚本是为了方便像我这种小小白萌新更加容易去使用 V2Ray,配置 V2Ray。希望对你有帮助 ^_^
安装或卸载
要求:Ubuntu 16+ / Debian 8+ / CentOS 7+ 系统 推荐使用 Debian 9 系统,脚本会自动启用 BBR 优化。
备注:不推荐使用 Debian 8 系统,因为 Caddy 申请证书可能会出现一些莫名其妙的问题 我们推荐使用 搬瓦工VPS,稳定,快速,针对中国线路专门优化,无须担心跑路,服务好,并且支持退款。
安装命令:
bash <(curl -s -L https://git.io/v2ray.sh)
如果提示 curl: command not found ,那是因为你的 VPS 没装 Curl
ubuntu/debian 系统安装 Curl 方法:
apt-get update -y && apt-get install curl -y
centos 系统安装 Curl 方法:
yum update -y && yum install curl -y
安装好 curl 之后就能安装脚本了
备注:安装完成后,输入 v2ray 即可管理 V2Ray
如果提示你的系统不支持此脚本,那么请尝试更换系统
快速管理命令:
v2ray info 查看 V2Ray 配置信息
v2ray config 修改 V2Ray 配置
v2ray link 生成 V2Ray 配置文件链接
v2ray infolink 生成 V2Ray 配置信息链接
v2ray qr 生成 V2Ray 配置二维码链接
v2ray ss 修改 Shadowsocks 配置
v2ray ssinfo 查看 Shadowsocks 配置信息
v2ray ssqr 生成 Shadowsocks 配置二维码链接
v2ray status 查看 V2Ray 运行状态
v2ray start 启动 V2Ray
v2ray stop 停止 V2Ray
v2ray restart 重启 V2Ray
v2ray log 查看 V2Ray 运行日志
v2ray update 更新 V2Ray
v2ray update.sh 更新 V2Ray 管理脚本
v2ray uninstall 卸载 V2Ray
原文:https://github.com/233boy/v2ray/wiki/V2Ray%E4%B8%80%E9%94%AE%E5%AE%89%E8%A3%85%E8%84%9A%E6%9C%AC
TCP BBR(Bottleneck Bandwidth and Round-trip propagation time)是由Google设计,于2016年发布的拥塞算法。以往大部分拥塞算法是基于丢包来作为降低传输速率的信号,而BBR则基于模型主动探测。该算法使用网络最近出站数据分组当时的最大带宽和往返时间来创建网络的显式模型。数据包传输的每个累积或选择性确认用于生成记录在数据包传输过程和确认返回期间的时间内所传送数据量的采样率。
Google在YouTube上应用该算法,将全球平均的YouTube网络吞吐量提高了4%,在一些国家超过了14%。根据实地测试,在部署了最新版内核并开启了 TCP BBR 的机器上,网速甚至可以提升好几个数量级。
从 4.9 开始,Linux 内核已经用上了该算法,并且对于QUIC可用。如果想在Linux使用BBR,那么首先就是判断内核版本是否大于4.9,如果符合版本标准,那么直接启动BBR就可以了,如果低于4.9,升级内核之后启动就行了。
下面就介绍一下在CentOS 7.3上安装TCP BBR的方法。
首先将Centos系统更新,更新到7.3版本。
yum update
查看系统版本,输出的release数值大于7.3即可。
cat /etc/redhat-release
对于某些机器来说,安装一下wget
yum install wget
方法1:自动安装,使用一键安装脚本
wget --no-check-certificate https://github.com/teddysun/across/raw/master/bbr.sh && chmod +x bbr.sh && ./bbr.sh
方法2:手动安装
使用下面命令安装elrepo并升级内核
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm yum --enablerepo=elrepo-kernel install kernel-ml -y
更新grub文件并重启(reboot后,ssh会断开,稍等一会儿重新连接)
egrep ^menuentry /etc/grub2.cfg | cut -f 2 -d \' grub2-set-default 0 reboot
开机后查看内核是否已更换为4.9
uname -r
启动BBR。依次执行下面命令就可以了。
echo "net.core.default_qdisc = fq" >> /etc/sysctl.conf echo "net.ipv4.tcp_congestion_control = bbr" >> /etc/sysctl.conf sysctl -p
验证bbr是否已经开启
A,验证当前TCP控制算法的命令:
sysctl net.ipv4.tcp_available_congestion_control
返回值一般为:
net.ipv4.tcp_available_congestion_control = bbr cubic reno
或者为:
net.ipv4.tcp_available_congestion_control = reno cubic bbr
B,验证BBR是否已经启动。
sysctl net.ipv4.tcp_congestion_control
返回值一般为:
net.ipv4.tcp_congestion_control = bbr
lsmod | grep bbr
返回值有 tcp_bbr 模块即说明 bbr 已启动。
1、使用一键安装脚本安装v2ray程序,选择选项4 websocket+tls,配置域名端口等信息并且选择不自动设置 TLS。
2、在宝塔中建立 一个相同域名的网站,填上SSL并修改网站配置文件,在配置文件的最后一个括号前添加如下代码并保存:
location / { proxy_redirect off; proxy_pass http://127.0.0.1:第一步设置的端口; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $http_host; }
3、停止并启动网站,然后获取连接即可。注意使用域名口端口一律为443。
整站代理:
// 你要镜像的网站. const upstream = 'zh.wikipedia.org' // 镜像网站的目录,比如你想镜像某个网站的二级目录则填写二级目录的目录名,镜像 google 用不到,默认即可. const upstream_path = '/' // 镜像站是否有手机访问专用网址,没有则填一样的. const upstream_mobile = 'zh.m.wikipedia.org' // 屏蔽国家和地区. const blocked_region = ['KP', 'SY', 'PK', 'CU'] // 屏蔽 IP 地址. const blocked_ip_address = ['0.0.0.0', '127.0.0.1'] // 镜像站是否开启 HTTPS. const https = true // 文本替换. const replace_dict = { '$upstream': '$custom_domain', '老地址': '新地址' } // 以下保持默认,不要动 addEventListener('fetch', event => { event.respondWith(fetchAndApply(event.request)); }) async function fetchAndApply(request) { const region = request.headers.get('cf-ipcountry').toUpperCase(); const ip_address = request.headers.get('cf-connecting-ip'); const user_agent = request.headers.get('user-agent'); let response = null; let url = new URL(request.url); let url_hostname = url.hostname; if (https == true) { url.protocol = 'https:'; } else { url.protocol = 'http:'; } if (await device_status(user_agent)) { var upstream_domain = upstream; } else { var upstream_domain = upstream_mobile; } url.host = upstream_domain; if (url.pathname == '/') { url.pathname = upstream_path; } else { url.pathname = upstream_path + url.pathname; } if (blocked_region.includes(region)) { response = new Response('Access denied: WorkersProxy is not available in your region yet.', { status: 403 }); } else if (blocked_ip_address.includes(ip_address)) { response = new Response('Access denied: Your IP address is blocked by WorkersProxy.', { status: 403 }); } else { let method = request.method; let request_headers = request.headers; let new_request_headers = new Headers(request_headers); new_request_headers.set('Host', url.hostname); new_request_headers.set('Referer', url.hostname); let original_response = await fetch(url.href, { method: method, headers: new_request_headers }) let original_response_clone = original_response.clone(); let original_text = null; let response_headers = original_response.headers; let new_response_headers = new Headers(response_headers); let status = original_response.status; new_response_headers.set('access-control-allow-origin', '*'); new_response_headers.set('access-control-allow-credentials', true); new_response_headers.delete('content-security-policy'); new_response_headers.delete('content-security-policy-report-only'); new_response_headers.delete('clear-site-data'); const content_type = new_response_headers.get('content-type'); if (content_type.includes('text/html') && content_type.includes('UTF-8')) { original_text = await replace_response_text(original_response_clone, upstream_domain, url_hostname); } else { original_text = original_response_clone.body } response = new Response(original_text, { status, headers: new_response_headers }) } return response; } async function replace_response_text(response, upstream_domain, host_name) { let text = await response.text() var i, j; for (i in replace_dict) { j = replace_dict[i] if (i == '$upstream') { i = upstream_domain } else if (i == '$custom_domain') { i = host_name } if (j == '$upstream') { j = upstream_domain } else if (j == '$custom_domain') { j = host_name } let re = new RegExp(i, 'g') text = text.replace(re, j); } return text; } async function device_status(user_agent_info) { var agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"]; var flag = true; for (var v = 0; v < agents.length; v++) { if (user_agent_info.indexOf(agents[v]) > 0) { flag = false; break; } } return flag; }
密码访问:
// 替换成你想镜像的站点 const upstream = 'google.com' // 如果那个站点有专门的移动适配站点,否则保持和上面一致 const upstream_mobile = 'm.google.com' // 密码访问 const openAuth = false const username = 'username' const password = 'password' // 你希望禁止哪些国家访问 const blocked_region = ['RU'] // 禁止自访问 const blocked_ip_address = ['0.0.0.0', '127.0.0.1'] // 替换成你想镜像的站点 const replace_dict = { '$upstream': '$custom_domain', '//google.com': '' } function unauthorized() { return new Response('Unauthorized', { headers: { 'WWW-Authenticate': 'Basic realm="goindex"', 'Access-Control-Allow-Origin': '*' }, status: 401 }); } function parseBasicAuth(auth) { try { return atob(auth.split(' ').pop()).split(':'); } catch (e) { return []; } } function doBasicAuth(request) { const auth = request.headers.get('Authorization'); if (!auth || !/^Basic [A-Za-z0-9._~+/-]+=*$/i.test(auth)) { return false; } const [user, pass] = parseBasicAuth(auth); return user === username && pass === password; } async function fetchAndApply(request) { if (request.method === 'OPTIONS') // allow preflight request return new Response('', { status: 200, headers: { 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Headers': '*', 'Access-Control-Allow-Methods': 'GET, POST, PUT, HEAD, OPTIONS' } }); if (openAuth && !doBasicAuth(request)) { return unauthorized(); } const region = request.headers.get('cf-ipcountry').toUpperCase(); const ip_address = request.headers.get('cf-connecting-ip'); const user_agent = request.headers.get('user-agent'); let response = null; let url = new URL(request.url); let url_host = url.host; if (url.protocol == 'http:') { url.protocol = 'https:' response = Response.redirect(url.href); return response; } if (await device_status(user_agent)) { upstream_domain = upstream } else { upstream_domain = upstream_mobile } url.host = upstream_domain; if (blocked_region.includes(region)) { response = new Response('Access denied: WorkersProxy is not available in your region yet.', { status: 403 }); } else if(blocked_ip_address.includes(ip_address)){ response = new Response('Access denied: Your IP address is blocked by WorkersProxy.', { status: 403 }); } else{ let method = request.method; let request_headers = request.headers; let new_request_headers = new Headers(request_headers); new_request_headers.set('Host', upstream_domain); new_request_headers.set('Referer', url.href); let original_response = await fetch(url.href, { method: method, headers: new_request_headers }) let original_response_clone = original_response.clone(); let original_text = null; let response_headers = original_response.headers; let new_response_headers = new Headers(response_headers); let status = original_response.status; new_response_headers.set('access-control-allow-origin', '*'); new_response_headers.set('access-control-allow-credentials', true); new_response_headers.delete('content-security-policy'); new_response_headers.delete('content-security-policy-report-only'); new_response_headers.delete('clear-site-data'); const content_type = new_response_headers.get('content-type'); if (content_type.includes('text/html') && content_type.includes('UTF-8')) { original_text = await replace_response_text(original_response_clone, upstream_domain, url_host); } else { original_text = original_response_clone.body } response = new Response(original_text, { status, headers: new_response_headers }) } return response; } addEventListener('fetch', event => { event.respondWith(fetchAndApply(event.request).catch(err => { console.error(err); new Response(JSON.stringify(err.stack), { status: 500, headers: { 'Content-Type': 'application/json' } }); })); }) async function replace_response_text(response, upstream_domain, host_name) { let text = await response.text() var i, j; for (i in replace_dict) { j = replace_dict[i] if (i == '$upstream') { i = upstream_domain } else if (i == '$custom_domain') { i = host_name } if (j == '$upstream') { j = upstream_domain } else if (j == '$custom_domain') { j = host_name } let re = new RegExp(i, 'g') text = text.replace(re, j); } return text; } async function device_status (user_agent_info) { var agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"]; var flag = true; for (var v = 0; v < agents.length; v++) { if (user_agent_info.indexOf(agents[v]) > 0) { flag = false; break; } } return flag; }
指定目录访问:
// 你要镜像的网站. const upstream = 'objectstorage.ap-seoul-1.oraclecloud.com' // 镜像网站的目录,比如你想镜像某个网站的二级目录则填写二级目录的目录名,镜像 google 用不到,默认即可. const upstream_path = '/test/' // 镜像站是否有手机访问专用网址,没有则填一样的. const upstream_mobile = 'objectstorage.ap-seoul-1.oraclecloud.com' // 屏蔽国家和地区. const blocked_region = [''] // 屏蔽 IP 地址. const blocked_ip_address = ['0.0.0.0', '127.0.0.1'] // 镜像站是否开启 HTTPS. const https = true // 文本替换.填你要镜像的网站 const replace_dict = { '$upstream': '$custom_domain', '//objectstorage.ap-seoul-1.oraclecloud.com': '' } // 以下保持默认,不要动 addEventListener('fetch', event => { event.respondWith(fetchAndApply(event.request)); }) async function fetchAndApply(request) { const region = request.headers.get('cf-ipcountry').toUpperCase(); const ip_address = request.headers.get('cf-connecting-ip'); const user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36" let response = null; let url = new URL(request.url); let url_hostname = url.hostname; if (https == true) { url.protocol = 'https:'; } else { url.protocol = 'http:'; } if (await device_status(user_agent)) { var upstream_domain = upstream; } else { var upstream_domain = upstream_mobile; } url.host = upstream_domain; if (url.pathname == '/') { url.pathname = upstream_path; } else { url.pathname = upstream_path + url.pathname; } if (blocked_region.includes(region)) { response = new Response('Access denied: WorkersProxy is not available in your region yet.', { status: 403 }); } else if (blocked_ip_address.includes(ip_address)) { response = new Response('Access denied: Your IP address is blocked by WorkersProxy.', { status: 403 }); } else { let method = request.method; let request_headers = request.headers; let new_request_headers = new Headers(request_headers); new_request_headers.set('Host', url.hostname); new_request_headers.set('Referer', url.hostname); let original_response = await fetch(url.href, { method: method, headers: new_request_headers }) let original_response_clone = original_response.clone(); let original_text = null; let response_headers = original_response.headers; let new_response_headers = new Headers(response_headers); let status = original_response.status; new_response_headers.set('access-control-allow-origin', '*'); new_response_headers.set('access-control-allow-credentials', true); new_response_headers.delete('content-security-policy'); new_response_headers.delete('content-security-policy-report-only'); new_response_headers.delete('clear-site-data'); const content_type = new_response_headers.get('content-type'); if (content_type.includes('text/html') && content_type.includes('UTF-8')) { original_text = await replace_response_text(original_response_clone, upstream_domain, url_hostname); } else { original_text = original_response_clone.body } response = new Response(original_text, { status, headers: new_response_headers }) } return response; } async function replace_response_text(response, upstream_domain, host_name) { let text = await response.text() var i, j; for (i in replace_dict) { j = replace_dict[i] if (i == '$upstream') { i = upstream_domain } else if (i == '$custom_domain') { i = host_name } if (j == '$upstream') { j = upstream_domain } else if (j == '$custom_domain') { j = host_name } let re = new RegExp(i, 'g') text = text.replace(re, j); } return text; } async function device_status(user_agent_info) { var agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"]; var flag = true; for (var v = 0; v < agents.length; v++) { if (user_agent_info.indexOf(agents[v]) > 0) { flag = false; break; } } return flag; }
更新:解决workers.dev被墙的问题。
1、在cloudflare DNS下解析域名到任意IP,并开通cdn。
2、在cloudflare域名下添加workers路由,格式为 xxx.domain.com/*,并指向对应的workers即可解决被墙问题
使用宝塔创建好网站。
新版宝塔面板直接在反向代理的替换地址填写上需要替换的地址。例如upload.wikimedia.org,wikimedia.org
第二种方法,修改网站配置文件。在配置文件中添加如下两行代码
sub_filter "upload.wikimedia.org" "wikipic.kongwuzi.workers.dev"; sub_filter "wikimedia.org" "wikimedia.kongwuzi.workers.dev";
其实CentOS 8内核版本已经高于4.1,因此我们无需再更新内核,直接开启就可以了
写入配置到/etc/sysctl.conf,并加载生效:
echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf sysctl -p
检查BBR加载状态:
sysctl -n net.ipv4.tcp_congestion_control lsmod | grep bbr