Skip to content

Commit

Permalink
fin
Browse files Browse the repository at this point in the history
  • Loading branch information
aditya-shri committed Dec 18, 2020
1 parent 0a6a390 commit 69d1e34
Show file tree
Hide file tree
Showing 9 changed files with 952 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.

75 changes: 75 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# One-click Shadowsocks+V2Ray-plugin to quickly deploy to Heroku

Click the button below to deploy, and remember to order a Star if it works:

[![Deploy](https://www.herokucdn.com/deploy/button.png)](https://heroku.com/deploy)
---

Native V2Ray deployment: <https://github.com/ygcaicn/v2ray-heroku>

---

## 0. Attention

Deployment requires registration of a heroku account, a ladder is required when registering a heroku account (otherwise the verification code cannot be brushed out), an email address that can receive verification codes normally (@qq.com, @163.com are not acceptable), gmail is conditional
Best, no conditions recommend outlook <https://login.live.com/> here.

## 1. Verification

After the server is deployed, click open app to display the webpage normally. After the address is filled with the path (for example: <https://test.herokuapp.com/static>), the 404 page is displayed, which means the deployment is successful.

## 2. Client Configuration

QR code address: https://test.herokuapp.com/qr_img/v2.png
(Change test to your own app name, if you change QR_Path, also change the corresponding qr_img to the modified one)

Use the client to scan the QR code.

**or**

Configuration file address: https://test.herokuapp.com/qr_img

Copy after opening and import it on the client.

**or**

Manual configuration:

```sh
Server: test.herokuapp.com (change test to your app name)
Port: 443
Password: The password filled in during deployment
Encry Method: RC4-MD5 (or other methods you fill in)
Plugin: v2ray
Plugin Transport mode: websocket-tls
Hostname: Same as Server
Path: The path you filled in during deployment
```

Those without a client can also download from here (Android):

[shadowsocks](https://github.com/shadowsocks/shadowsocks-android/releases/download/v5.0.5/shadowsocks--universal-5.0.5.apk)

[v2ray-plugin](https://github.com/shadowsocks/v2ray-plugin-android/releases/download/v1.3.1/v2ray-arm64-v8a-1.3.1.apk)

windows:

<https://github.com/shadowsocks/shadowsocks-windows/wiki/Shadowsocks-Windows-%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E>

## 3. Update

To update the v2ray-plugin version, visit <https://dashboard.heroku.com/apps> and select the deployed app. If the VER variable is latest. Directly select More --> Restart all dynos, the program will restart automatically, and the progress can be confirmed through view Logs. (Update the specified version: Settings --> Reveal Config Varsapp -->VER, modify to the required version number, such as 1.2)

2020/03/01 The current version is working normally:

+ shadowsocks-libev: 3.3.4+ds-2(debian apt)

+ v2ray-plugin: v1.3.0

# Reference

https://github.com/xiangrui120/v2ray-heroku-undone

https://hub.docker.com/r/shadowsocks/shadowsocks-libev

https://github.com/shadowsocks/v2ray-plugin
44 changes: 44 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "Shadowsocks+V2Ray-plugin快速部署",
"description": "Deploy Shadowsocks+V2Ray-plugin to Heroku.",
"keywords": ["V2ray", "Shadowsocks", "V2Ray-plugin"],
"env": {
"ENCRYPT": {
"description": "加密方式,由于有https加持,选最简单的就可以,默认:rc4-md5,其它的有(aes-256-cfb,chacha20-ietf-poly1305,salsa20,chacha20-ietf等.)",
"value": "rc4-md5"
},
"PASSWORD": {
"description": "shadowsocks的密码,可以使用uuid作为密码(http://www.uuid.online/在线生成)",
"value": "5c301bb8-6c77-41a0-a606-4ba11bbab084"
},

"VER": {
"description": "v2ray-plugin版本,默认latest安装最新版本,可以去https://github.com/shadowsocks/v2ray-plugin/releasesV2Ray选择版本 (例如:1.1.0)",
"value": "latest"
},

"V2_Path": {
"description": "Path路径,默认/s233,为了安全你也可以使用uuid替换s233,/不能少。如果开启反代,不要与反代uri重复",
"value": "/s233"
},

"AppName": {
"description": "请输入最上方填写的App Name,用于生成配置和二维码,如果不想生成输入no",
"value": "no"
},

"QR_Path": {
"description": "二维码和配置链接路径,默认qr_img,为了保密性你也可以使用uuid,但是不能与V2_Path相同。如AppName变量为no,此变量没有作用",
"value": "/qr_img"
},

"ProxySite": {
"description": "反代一个网站,例如:www.ietf.org,不填写表示使用本地静态网页文件。",
"value": "www.ietf.org"
}

},
"website": "",
"repository": "",
"stack": "container"
}
30 changes: 30 additions & 0 deletions conf/nginx_ss.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# 顶格注释内容在sed处理时将被剔除,不会出现在最后的配置文件中

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

root /wwwroot;

resolver 8.8.8.8:53;
location / {
proxy_pass https://${ProxySite};
}
location ${QR_Path} {
root /wwwroot;
}
location = ${V2_Path} {
if ($http_upgrade != "websocket") { # WebSocket协商失败时返回404
return 404;
}
proxy_redirect off;
proxy_pass http://127.0.0.1:2333;
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 v2ray access.log
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
15 changes: 15 additions & 0 deletions conf/shadowsocks-libev_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# 顶格注释内容在sed处理时将被剔除,不会出现在最后的配置文件中
# 在heroku上fast_open必须为false
{
"server":"127.0.0.1",
"server_port":"2333",
"password":"${PASSWORD}",
"timeout":300,
"method":"${ENCRYPT}",
"mode": "tcp_and_udp",
"fast_open":false,
"reuse_port":true,
"no_delay":true,
"plugin": "v2ray-plugin",
"plugin_opts":"server;path=${V2_Path}"
}
94 changes: 94 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#!/bin/bash

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

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

if [[ -z "${ENCRYPT}" ]]; then
ENCRYPT="rc4-md5"
fi


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

if [[ -z "${QR_Path}" ]]; then
QR_Path="/qr_img"
fi
echo ${QR_Path}


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

mkdir /v2raybin
cd /v2raybin
V2RAY_URL="https://github.com/shadowsocks/v2ray-plugin/releases/download/${V_VER}/v2ray-plugin-linux-amd64-${V_VER}.tar.gz"
echo ${V2RAY_URL}
wget --no-check-certificate ${V2RAY_URL}
tar -zxvf v2ray-plugin-linux-amd64-$V_VER.tar.gz
rm -rf v2ray-plugin-linux-amd64-$V_VER.tar.gz
mv v2ray-plugin_linux_amd64 /usr/bin/v2ray-plugin
rm -rf /v2raybin

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

if [ ! -d /etc/shadowsocks-libev ]; then
mkdir /etc/shadowsocks-libev
fi

# TODO: bug when PASSWORD contain '/'
sed -e "/^#/d"\
-e "s/\${PASSWORD}/${PASSWORD}/g"\
-e "s/\${ENCRYPT}/${ENCRYPT}/g"\
-e "s|\${V2_Path}|${V2_Path}|g"\
/conf/shadowsocks-libev_config.json > /etc/shadowsocks-libev/config.json
echo /etc/shadowsocks-libev/config.json
cat /etc/shadowsocks-libev/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|\${QR_Path}|${QR_Path}|g"\
-e "$s"\
/conf/nginx_ss.conf > /etc/nginx/conf.d/ss.conf
echo /etc/nginx/conf.d/ss.conf
cat /etc/nginx/conf.d/ss.conf


if [ "$AppName" = "no" ]; then
echo "不生成二维码"
else
[ ! -d /wwwroot/${QR_Path} ] && mkdir /wwwroot/${QR_Path}
plugin=$(echo -n "v2ray;path=${V2_Path};host=${AppName}.herokuapp.com;tls" | sed -e 's/\//%2F/g' -e 's/=/%3D/g' -e 's/;/%3B/g')
ss="ss://$(echo -n ${ENCRYPT}:${PASSWORD} | base64 -w 0)@${AppName}.herokuapp.com:443?plugin=${plugin}"
echo "${ss}" | tr -d '\n' > /wwwroot/${QR_Path}/index.html
echo -n "${ss}" | qrencode -s 6 -o /wwwroot/${QR_Path}/v2.png
fi

ss-server -c /etc/shadowsocks-libev/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 69d1e34

Please sign in to comment.