diff --git a/Dockerfile b/Dockerfile
index 95252b3..e462219 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,7 +1,13 @@
FROM v2fly/v2fly-core:latest
-RUN wget https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 -O /root/cloudflared
-RUN chmod +x /root/cloudflared
+RUN apk add nginx
+RUN apk add gettext
+
+COPY html /root/html/
+
+COPY config.json.tp /root/
+COPY nginx.template.conf /root/
+
ADD startup.sh /startup.sh
RUN chmod +x /startup.sh
diff --git a/config.json.tp b/config.json.tp
new file mode 100644
index 0000000..f0af83d
--- /dev/null
+++ b/config.json.tp
@@ -0,0 +1,48 @@
+{
+ "policy": {
+ "levels": {
+ "0": {
+ "handshake": 5,
+ "connIdle": 300,
+ "uplinkOnly": 2,
+ "downlinkOnly": 5,
+ "statsUserUplink": false,
+ "statsUserDownlink": false,
+ "bufferSize": 10240
+ }
+ },
+ "system": {
+ "statsInboundUplink": false,
+ "statsInboundDownlink": false,
+ "statsOutboundUplink": false,
+ "statsOutboundDownlink": false
+ }
+ },
+ "inbounds": [
+ {
+ "port": 8080,
+ "protocol": "vless",
+ "settings": {
+ "clients": [
+ {
+ "id": "$UUID",
+ "level": 0
+ }
+ ],
+ "decryption": "none"
+ },
+ "streamSettings": {
+ "network": "ws",
+ "security": "none",
+ "wsSettings": {
+ "path": "/v2ws"
+ }
+ }
+ }
+ ],
+ "outbounds": [
+ {
+ "protocol": "freedom"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/html/50x.html b/html/50x.html
new file mode 100644
index 0000000..3dde65b
--- /dev/null
+++ b/html/50x.html
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+ 500
+
+
+ 500
+
+
\ No newline at end of file
diff --git a/html/index.html b/html/index.html
new file mode 100644
index 0000000..b0e75c9
--- /dev/null
+++ b/html/index.html
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+ Document
+
+
+
+ My first website
+
+
\ No newline at end of file
diff --git a/html/test.js b/html/test.js
new file mode 100644
index 0000000..d8e839b
--- /dev/null
+++ b/html/test.js
@@ -0,0 +1 @@
+alert("test alert")
\ No newline at end of file
diff --git a/nginx.template.conf b/nginx.template.conf
new file mode 100644
index 0000000..fee7b20
--- /dev/null
+++ b/nginx.template.conf
@@ -0,0 +1,57 @@
+user root;
+worker_processes 4; # Heroku dynos have at least four cores.
+
+error_log stderr;
+pid /var/run/nginx.pid;
+
+events {
+ worker_connections 1024;
+}
+
+http {
+ include /etc/nginx/mime.types;
+ access_log /dev/stdout;
+ server_tokens off; # Hide nginx version in Server header & page footers
+
+# include /etc/nginx/conf.d/*.conf;
+
+ server {
+ listen $PORT;
+
+ #charset koi8-r;
+ #access_log /var/log/nginx/host.access.log main;
+
+ # 用来proxy https nginx 暂时不支持proxy pass http2.0, 但是可以用SIN 来route
+ # location /dash/ {
+ # proxy_pass https://dash.zizi.press:4000/;
+ # }
+ location / {
+ root /root/html;
+ index index.html index.htm;
+ }
+
+ error_page 500 502 503 504 /50x.html;
+ location = /50x.html {
+ root /root/html;
+ }
+
+ location /v2ws { # 与 V2Ray 配置中的 path 保持一致
+ if ($http_upgrade != "websocket") { # WebSocket协商失败时返回404
+ return 404;
+ }
+ proxy_redirect off;
+ proxy_pass http://127.0.0.1:8080; # 假设WebSocket监听在环回地址的10000端口上
+ proxy_http_version 1.1;
+ proxy_set_header Upgrade $http_upgrade;
+ proxy_set_header Connection "upgrade";
+ proxy_set_header Host $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;
+ }
+}
+
+}
+
+
+
diff --git a/startup.sh b/startup.sh
index cee8e6b..209e748 100644
--- a/startup.sh
+++ b/startup.sh
@@ -1,58 +1,16 @@
#!/bin/sh
-cat << EOF > /etc/v2ray/config.json
-{
- "policy": {
- "levels": {
- "0": {
- "handshake": 5,
- "connIdle": 300,
- "uplinkOnly": 2,
- "downlinkOnly": 5,
- "statsUserUplink": false,
- "statsUserDownlink": false,
- "bufferSize": 10240
- }
- },
- "system": {
- "statsInboundUplink": false,
- "statsInboundDownlink": false,
- "statsOutboundUplink": false,
- "statsOutboundDownlink": false
- }
- },
- "inbounds": [
- {
- "port": $PORT,
- "protocol": "vless",
- "settings": {
- "clients": [
- {
- "id": "$UUID",
- "level": 0
- }
- ],
- "decryption": "none"
- },
- "streamSettings": {
- "network": "ws",
- "security": "none"
- }
- }
- ],
- "outbounds": [
- {
- "protocol": "freedom"
- }
- ]
-}
-EOF
+envsubst < /root/config.json.tp > /root/config.json
+envsubst '\$PORT' < /root/nginx.template.conf > /root/nginx.conf
+
# Run V2Ray
if [[ $TUNNEL_TOKEN ]]; then
echo 'has tunnel token, run cloudflared tunnel'
-/usr/bin/v2ray -config /etc/v2ray/config.json & /root/cloudflared tunnel --no-autoupdate run --token $TUNNEL_TOKEN
+wget https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 -O /root/cloudflared
+chmod +x /root/cloudflared
+/usr/bin/v2ray -config /root/config.json & /root/cloudflared tunnel --no-autoupdate run --token $TUNNEL_TOKEN & nginx -c /root/nginx.conf -g 'daemon off;'
else
-/usr/bin/v2ray -config /etc/v2ray/config.json
+/usr/bin/v2ray -config /root/config.json & nginx -c /root/nginx.conf -g 'daemon off;'
fi