Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ygcaicn committed Jan 21, 2021
0 parents commit e0eb6f4
Show file tree
Hide file tree
Showing 9 changed files with 899 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM debian:sid

RUN set -ex\
&& apt update -y \
&& apt upgrade -y \
&& apt install -y wget unzip qrencode\
&& apt install -y shadowsocks-libev\
&& apt install -y nginx\
&& apt autoremove -y

COPY wwwroot.tar.gz /wwwroot/wwwroot.tar.gz
COPY conf/ /conf
COPY entrypoint.sh /entrypoint.sh

RUN chmod +x /entrypoint.sh

CMD /entrypoint.sh
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Xray快速部署到Heroku

点击下面按钮部署,好用的话记得点个Star:

[![Deploy](https://www.herokucdn.com/deploy/button.png)](https://heroku.com/deploy)
34 changes: 34 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "Xray快速部署",
"description": "Deploy Xray to Heroku.",
"keywords": ["V2ray", "Xray"],
"env": {
"ProxySite": {
"description": "反代一个网站,例如:www.ietf.org,不填写表示使用本地静态网页文件。",
"value": "www.ietf.org"
},

"UUID": {
"description": "Vless uuid(http://www.uuid.online/在线生成)",
"value": "5c301bb8-6c77-41a0-a606-4ba11bbab084"
},

"Xray_Path": {
"description": "Path路径,默认/s233,为了安全你也可以使用uuid替换s233,/不能少。如果开启反代,不要与反代网站存在的uri相同",
"value": "/s233"
},

"Share_Path": {
"description": "Share path, /share233订阅链接,/share233/vless.png二维码",
"value": "/share233"
},

"VER": {
"description": "Xray版本,默认latest安装最新版本,可以去https://github.com/XTLS/Xray-core/releases选择版本 (例如:1.2.2)",
"value": "latest"
}
},
"website": "",
"repository": "",
"stack": "container"
}
51 changes: 51 additions & 0 deletions conf/Xray.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# 顶格注释内容在sed处理时将被剔除,不会出现在最后的配置文件中
# 在heroku上fast_open必须为false
{
"log": {
"loglevel": "warning"
},
"routing": {
"domainStrategy": "AsIs",
"rules": [
{
"type": "field",
"ip": [
"geoip:private"
],
"outboundTag": "block"
}
]
},
"inbounds": [
{
"listen": "0.0.0.0",
"port": 12345,
"protocol": "vmess",
"settings": {
"clients": [
{
"id": "${UUID}"
}
]
},
"streamSettings": {
"network": "ws",
"security": "none"
"wsSettings": {
"acceptProxyProtocol": true,
"path": "${Xray_Path}",
},
}
}
],
"outbounds": [
{
"protocol": "freedom",
"tag": "direct"
},
{
"protocol": "blackhole",
"tag": "block"
}
]
}
32 changes: 32 additions & 0 deletions conf/nginx.template.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# 顶格注释内容在sed处理时将被剔除,不会出现在最后的配置文件中

server {
listen ${PORT};
listen [::]:${PORT};

root /wwwroot;

resolver 8.8.8.8:53;
location / {
proxy_pass https://${ProxySite};
}

location ${Share_Path} {
root /wwwroot;
}

location = ${Xray_Path} {
if ($http_upgrade != "websocket") { # WebSocket协商失败时返回404
return 404;
}
proxy_redirect off;
proxy_pass http://127.0.0.1:12345;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
# Show real IP in access.log
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
83 changes: 83 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/bin/bash

#Xray版本
if [[ -z "${VER}" ]]; then
VER="latest"
fi
echo ${VER}

if [[ -z "${Xray_Path}" ]]; then
Xray_Path="/s233"
fi
echo ${Xray_Path}

if [[ -z "${UUID}" ]]; then
UUID="5c301bb8-6c77-41a0-a606-4ba11bbab084"
fi
echo ${UUID}

if [[ -z "${Share_Path}" ]]; then
Share_Path="/share233"
fi
echo ${Share_Path}

if [ "$VER" = "latest" ]; then
VER=`wget -qO- "https://api.github.com/repos/XTLS/Xray-core/releases/latest" | sed -n -r -e 's/.*"tag_name".+?"([vV0-9\.]+?)".*/\1/p'`
[[ -z "${VER}" ]] && VER="v1.2.2"
else
VER="v$VER"
fi

mkdir /xraybin
cd /xraybin
RAY_URL="https://github.com/XTLS/Xray-core/releases/download/${V_VER}/Xray-linux-64.zip"
echo ${RAY_URL}
wget --no-check-certificate ${RAY_URL}
unzip Xray-linux-64.zip
rm -f Xray-linux-64.zip
chmod +x ./xray

cd /wwwroot
tar xvf wwwroot.tar.gz
rm -rf wwwroot.tar.gz


sed -e "/^#/d"\
-e "s/\${UUID}/${UUID}/g"\
-e "s|\${Xray_Path}|${Xray_Path}|g"\
/conf/Xray.template.json > /xraybin/config.json
echo /xraybin/config.json
cat /xraybin/config.json

if [[ -z "${ProxySite}" ]]; then
s="s/proxy_pass/#proxy_pass/g"
echo "site:use local wwwroot html"
else
s="s|\${ProxySite}|${ProxySite}|g"
echo "site: ${ProxySite}"
fi

sed -e "/^#/d"\
-e "s/\${PORT}/${PORT}/g"\
-e "s|\${V2_Path}|${V2_Path}|g"\
-e "s|\${Share_Path}|${Share_Path}|g"\
-e "$s"\
/conf/nginx.template.conf > /etc/nginx/conf.d/ray.conf
echo /etc/nginx/conf.d/ray.conf
cat /etc/nginx/conf.d/ray.conf


if [ "$AppName" = "no" ]; then
echo "不生成分享链接"
else
[ ! -d /wwwroot/${Share_Path} ] && mkdir /wwwroot/${Share_Path}
path=$(echo -n ${V2_Path}" | sed -e 's/\//%2F/g' -e 's/=/%3D/g' -e 's/;/%3B/g')
link="vless://${UUID}@${AppName}.herokuapp.com:443?path=${path}&security=tls&encryption=none&type=ws#${AppName}-herokuapp"
echo -n "${link}" | tr -d '\n' > /wwwroot/${Share_Path}/index.html
echo -n "${link}" | qrencode -s 6 -o /wwwroot/${Share_Path}/vless.png
fi
cd /xraybin
./xray run -c ./config.json &
rm -rf /etc/nginx/sites-enabled/default
nginx -g 'daemon off;'
3 changes: 3 additions & 0 deletions heroku.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build:
docker:
web: Dockerfile
Binary file added wwwroot.tar.gz
Binary file not shown.

0 comments on commit e0eb6f4

Please sign in to comment.