From 66df24001eaec2152aa480fbcc79255f6a6755d1 Mon Sep 17 00:00:00 2001 From: Robert Zhou Date: Sat, 2 May 2020 11:06:19 +0100 Subject: [PATCH] add badges --- .gitignore | 14 ++++++++ Dockerfile | 67 +++++++++++++++++++++++++++++++++++ README.md | 33 +++++++++++++++-- docker-build.sh | 8 +++++ docker-conf/config.json | 30 ++++++++++++++++ docker-conf/default.conf | 22 ++++++++++++ docker-conf/html/404.html | 10 ++++++ docker-conf/html/index.html | 10 ++++++ docker-conf/localtime | Bin 0 -> 388 bytes docker-conf/nginx.conf | 30 ++++++++++++++++ docker-conf/supervisord.conf | 27 ++++++++++++++ entrypoint.sh | 6 ++++ v2ray-compose-template.yml | 23 ++++++++++++ 13 files changed, 278 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 docker-build.sh create mode 100644 docker-conf/config.json create mode 100644 docker-conf/default.conf create mode 100644 docker-conf/html/404.html create mode 100644 docker-conf/html/index.html create mode 100644 docker-conf/localtime create mode 100644 docker-conf/nginx.conf create mode 100644 docker-conf/supervisord.conf create mode 100644 entrypoint.sh create mode 100644 v2ray-compose-template.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1f47bf2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +# https://www.atlassian.com/git/tutorials/saving-changes/gitignore + +.env +.idea +deploy.sh + +#letsencrypt generated certificates +letsencrypt/ + +#logs +logs/ + +#run folder - files in these folders are programme generated +run/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..72f1a44 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,67 @@ +FROM ubuntu:latest as builder + +RUN apt-get update +RUN apt-get install curl -y +RUN curl -L -o /tmp/go.sh https://install.direct/go.sh +RUN chmod +x /tmp/go.sh +RUN /tmp/go.sh + + +FROM alpine:3.11 + +LABEL Maintainer="George Zhou" \ + Description="V2Ray all-in-one image with ws-tls option based on Alpine Linux." \ + Language="HTML" \ + OS="Alpine Linux" \ + Service="V2Ray" \ + Content="V2RAY" + +ENV CLIENT_ID "2e5762cc-20d2-42b1-b0ad-cbe55dc5fa35" +ENV CLIENT_ALTERID 64 +ENV CLIENT_WSPATH "/allproducts" +#ENV VER=4.23.1 +ENV PATH /usr/bin/v2ray:$PATH + +# ensure www-data user exists +RUN set -eux; \ + addgroup -g 82 -S www-data; \ + adduser -u 82 -D -S -G www-data www-data; +# 82 is the standard uid/gid for "www-data" in Alpine + +#install v2ray +COPY --from=builder /usr/bin/v2ray/v2ray /usr/bin/v2ray/ +COPY --from=builder /usr/bin/v2ray/v2ctl /usr/bin/v2ray/ +COPY docker-conf/config.json /etc/v2ray/config.json + +RUN set -ex && \ + apk update && \ + apk --no-cache add ca-certificates \ + nginx \ + supervisor && \ + rm -rf /var/cache/apk/* && \ + mkdir /var/log/v2ray/ &&\ + chmod +x /usr/bin/v2ray/v2ctl && \ + chmod +x /usr/bin/v2ray/v2ray + +RUN rm -rf /etc/localtime +COPY docker-conf/localtime /etc/ + +# configure Nginx +COPY docker-conf/nginx.conf /etc/nginx/ +COPY docker-conf/default.conf /etc/nginx/conf.d/ +# configure supervisord +COPY docker-conf/supervisord.conf /etc/supervisor/conf.d/supervisord.conf + +# web content volume +VOLUME /var/www/html +WORKDIR /var/www/html +COPY docker-conf/html/* /var/www/html/ +RUN chown -R www-data.www-data /var/www + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh +ENTRYPOINT [ "/entrypoint.sh" ] + +EXPOSE 80 + +CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] diff --git a/README.md b/README.md index 0b59412..e477988 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,31 @@ -# v2ray-nginx-docker -Easy Docker deployment for V2ray + WS +TLS with Nginx, free SSL and Traefik +# v2ray-arukas-all-in-one + +![](https://img.shields.io/badge/language-Docker-orange.svg) + +A v2ray docker image work with nginx for Arukas/IBM/okteto + +- v2ray work with websocket +- v2ray request proxy_pass by nginx +- custom v2ray settings +- add environment variables to edit optional setting + - CLIENT_ID (default ad806487-2d26-4636-98b6-ab85cc8521f7) + - CLIENT_ALTERID (default 64) + - CLIENT_WSPATH (default /ws) + - VER (default 4.19.1) +- don't need custom domain and ssl certificate +- only cost 1 pods + +**USE: deploy this image and add default secure route with port 8080 in arukas** + +- path to v2ray: https://your.domain/fuckgfw_letscrossgfw +- path to websites: /usr/share/nginx/html/ + +实例教程参考 : + +- V2Ray+WebSocket+TLS+Nginx 配置与使用教程 +- https://toutyrater.github.io/advanced/wss_and_web.html +- https://bawodu.com/openshift-v2ray/ +- Official Dockerfile +- https://github.com/v2ray/ext +- https://toutyrater.github.io/app/docker-deploy-v2ray.html +- SSR proxy settings - a great explaination diff --git a/docker-build.sh b/docker-build.sh new file mode 100644 index 0000000..7f7d735 --- /dev/null +++ b/docker-build.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +TAG="4.23" +docker build -t alphacodinghub/v2ray-nginx:$TAG . +docker build -t alphacodinghub/v2ray-nginx:latest . + +# V2ray versions: +# 4.23.1 2020.05.01 diff --git a/docker-conf/config.json b/docker-conf/config.json new file mode 100644 index 0000000..d82b7e3 --- /dev/null +++ b/docker-conf/config.json @@ -0,0 +1,30 @@ +{ + "log": { + "access": "/var/log/v2ray/access.log", + "error": "/var/log/v2ray/error.log", + "loglevel": "debug" + }, + "inbound": { + "port": 30003, + "listen":"127.0.0.1", + "protocol": "vmess", + "settings": { + "clients": [ + { + "id": "CLIENT_ID", + "alterId": CLIENT_ALTERID + } + ] + }, + "streamSettings":{ + "network":"ws", + "wsSettings": { + "path": "CLIENT_WSPATH" + } + } + }, + "outbound": { + "protocol": "freedom", + "settings": {} + } +} diff --git a/docker-conf/default.conf b/docker-conf/default.conf new file mode 100644 index 0000000..8aa9304 --- /dev/null +++ b/docker-conf/default.conf @@ -0,0 +1,22 @@ +server { + server_name _; + listen 80; + + location / { + root /var/www/html; + index index.html index.htm; + } + + location CLIENT_WSPATH { + proxy_redirect off; + proxy_pass http://127.0.0.1:30003; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host $http_host; + } + + location ~ \.php$ { + deny all; + } +} diff --git a/docker-conf/html/404.html b/docker-conf/html/404.html new file mode 100644 index 0000000..23e030e --- /dev/null +++ b/docker-conf/html/404.html @@ -0,0 +1,10 @@ + + + + HTML Meta Tag + + + +

Welcome to Baidu world!

+ + \ No newline at end of file diff --git a/docker-conf/html/index.html b/docker-conf/html/index.html new file mode 100644 index 0000000..23e030e --- /dev/null +++ b/docker-conf/html/index.html @@ -0,0 +1,10 @@ + + + + HTML Meta Tag + + + +

Welcome to Baidu world!

+ + \ No newline at end of file diff --git a/docker-conf/localtime b/docker-conf/localtime new file mode 100644 index 0000000000000000000000000000000000000000..7853673662f9a3b53f8fe14b35dc99c7cc6c094e GIT binary patch literal 388 zcmZvXO=`kW6h?1sK#?M~3$WVQBqE)3Ae~Bt5~(9I3Q}=m&Fr~>_?F;$T!D31C>?YY z!C@!uJsB14_qd$*L&A5GG+RE%St@$NkSiVbwf)So`|rTKeKhRhD=k{Pf!t&p)6Q46 z6EDo|%h-Co$aJ4xCg zhBS59U;b$FLDYlvE2$kJJt1BBh`xl*klv8)kp2({hzG$1;!{$cAYLWat>T<4k@Y8! Vs_2%AwdaW{{?QbvtMUC~{TI?%RE+=t literal 0 HcmV?d00001 diff --git a/docker-conf/nginx.conf b/docker-conf/nginx.conf new file mode 100644 index 0000000..353846a --- /dev/null +++ b/docker-conf/nginx.conf @@ -0,0 +1,30 @@ +worker_processes 1; + +error_log /var/log/nginx/error.log warn; +pid /var/run/nginx.pid; + + +events { + worker_connections 1024; +} + + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; + + sendfile on; + #tcp_nopush on; + + keepalive_timeout 65; + + #gzip on; + + include /etc/nginx/conf.d/*.conf; +} diff --git a/docker-conf/supervisord.conf b/docker-conf/supervisord.conf new file mode 100644 index 0000000..2a3b958 --- /dev/null +++ b/docker-conf/supervisord.conf @@ -0,0 +1,27 @@ +[supervisord] +nodaemon=true +logfile=/var/log/supervisord.log +pidfile=/run/supervisord.pid + +[program:v2ray] +command=v2ray -config=/etc/v2ray/config.json +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +redirect_stderr=true +autorestart=false +startretries=0 + +[program:nginx] +command=nginx -g 'daemon off;' +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +redirect_stderr=true +autorestart=false +startretries=0 + +# The below configure can be applied when Docker orchestrator like Docker Swarm or K8S is used. +# By default, supervisor will attempt to restart a failed process. +# Refer to http://supervisord.org/configuration.html for more info. +#[eventlistener:processes] +#command=stop-supervisor.sh +#events=PROCESS_STATE_STOPPED, PROCESS_STATE_EXITED, PROCESS_STATE_FATAL \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..2665aa2 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,6 @@ +#!/bin/sh +sed -i "s/CLIENT_ID/$CLIENT_ID/g" /etc/v2ray/config.json +sed -i "s/CLIENT_ALTERID/$CLIENT_ALTERID/g" /etc/v2ray/config.json +sed -i "s#CLIENT_WSPATH#$CLIENT_WSPATH#g" /etc/v2ray/config.json +sed -i "s#CLIENT_WSPATH#$CLIENT_WSPATH#g" /etc/nginx/conf.d/default.conf +exec "$@" \ No newline at end of file diff --git a/v2ray-compose-template.yml b/v2ray-compose-template.yml new file mode 100644 index 0000000..a6dcc1a --- /dev/null +++ b/v2ray-compose-template.yml @@ -0,0 +1,23 @@ +version: '3.7' + +services: + ################################################ + #### v2ray server container ##### + ############################################## + achanchor-v2ray: + image: alphacodinghub/v2ray-nginx + container_name: achanchor-v2ray + restart: always + networks: + - web + labels: + #### Labels define the behavior and rules of the traefik proxy for this container #### + traefik.enable: true # <== Enable traefik to proxy this container + traefik.http.routers.achanchor-v2ray.rule: Host(`achanchor.${APP_DOMAIN}`) # <== Your Domain Name for the https rule + traefik.http.routers.achanchor-v2ray.entrypoints: web-secured # <== Defining entrypoint for https, **ref: line 31 + traefik.http.routers.achanchor-v2ray.tls.certresolver: mytlschallenge # <== Defining certsresolvers for https + +# networks and volumes +networks: + web: + external: true