This commit is contained in:
Robert Zhou
2020-05-08 23:18:53 +01:00
parent 2456e5a785
commit 62a03a5d1d
12 changed files with 225 additions and 62 deletions
+12 -3
View File
@@ -1,6 +1,15 @@
APP_NAME=myserver
APP_DOMAIN=example.com
ACME_EMAIL=myemail@example.com
#APP_NAME=myserver
#APP_DOMAIN=example.com
#ACME_EMAIL=myemail@example.com
APP_NAME=vs
APP_DOMAIN=alibaba-portal.com
ACME_EMAIL=alphacodinghub@outlook.com
LISTENING_PORT=3003
CLIENT_ID=2e5762cc-20d2-42b1-b0ad-cbe55dc5fa35
CLIENT_ALTERID=64
CLIENT_WSPATH=/allproducts
# with above settings, you can visit traefik dashboard at:
# https://traefik.example.com
+2 -1
View File
@@ -14,8 +14,9 @@ LABEL Maintainer="George Zhou<alphacodinghub@outlook.com >" \
Language="HTML" \
OS="Alpine Linux" \
Service="V2Ray" \
Content="V2RAY"
Content="V2RAY and Nginx server"
ENV LISTENING_PORT 3456
ENV CLIENT_ID "2e5762cc-20d2-42b1-b0ad-cbe55dc5fa35"
ENV CLIENT_ALTERID 64
ENV CLIENT_WSPATH "/allproducts"
+63 -21
View File
@@ -1,34 +1,76 @@
# v2ray-ws-tls-all-in-one
# v2ray websocks tls + web all-in-one Docker
<a href="https://github.com/alphacodinghub/v2ray-docker/"><img src="https://img.shields.io/badge/Docker-v2ray-4BC51D.svg?style=flat"></a>
![](https://img.shields.io/badge/language-Web-orange.svg)
![](https://img.shields.io/badge/platform-Docker-lightgrey.svg)[![](https://img.shields.io/badge/Traefik-v2.x-blue.svg)](https://containo.us/traefik/)
![](https://img.shields.io/badge/license-MIT-000000.svg)
**A v2ray docker image work with nginx**
## [中文指引请点击此处](https://github.com/alphacodinghub/v2ray/blob/master/README_cn.md)
- 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.23.1)
- don't need custom domain and ssl certificate
- only cost 1 pods
## V2Ray quick deployment using Traefik
**USE: deploy this image and add default secure route with port 8080 in arukas**
- The Docker image is based on the latest official release and integrated with Nginx and a basic website.
- Deployment using Traefik, easy operation.
- Traefik automatically manages ssl certificates.
- A basic static website is integrated with the image. It will redirect to baidu.com by default however you can replace it with your own real website.
- V2Ray parameters can be easily customized using the `.env` file. You don't need to change the `docker-compose.yml` file.
- Main parameters you can customize indlude domain name, UUID, v2ray listening port, and the camouflaged path.
- path to v2ray: https://your.domain/fuckgfw_letscrossgfw
- path to websites: /usr/share/nginx/html/
## V2Ray server setup and configuration
实例教程参考
### 1. VPS
- [V2Ray+WebSocket+TLS+Nginx 配置与使用教程](https://doubibackup.com/v2ray-ws-tls-nginx.html)
- https://toutyrater.github.io/advanced/wss_and_web.html
- https://bawodu.com/openshift-v2ray/
- To buy a VPS and install Docker engine and git tool.
- To buy a domain, e.g. example.com.
- Choose an app name for your V2Ray server, e.g. `myapp`. Your camouflaged website url will then be `https://myapp.example.com`.
- Configure the DNS to point the domain `myapp.example.com` to the IP address of your VPS.
### 2. Clone this project to your VPS
```
- mkdir /app
- cd /app
- git clone https://github.com/alphacodinghub/v2ray-nginx-docker.git
- cd v2ray-nginx-docker
```
### 3. Configure VPS
To edit `.env` file and set necessary parameters. These three parameters must be set to your own values: APP_NAME (as chosen in Step 1), APP_DOMAIN, ACME_EMAIL (your email address for Let's Encrypt to apply for and renew ssl certificates). All other parameters can use the default values as provided. The final `.env` file should look like this (you should set your own values):
```
APP_NAME=myapp
APP_DOMAIN=example.com
ACME_EMAIL=myemail@example.com
LISTENING_PORT=3033
CLIENT_ID=2e5762cc-20d2-42b1-b0ad-cbe55dc5fa35
CLIENT_ALTERID=64
CLIENT_WSPATH=/allproducts
```
In the above settings, `CLIENT_WSPATH` is the so-called camouflaged path which should be set to the same value at the VPS server and user clients.
### 4. Website settings
By default, the caouflaged website will be redirected to baidu.com. You can copy your real website content to `./conf/html` folder to replace original files.
### 5. Start V2Ray server
After above settings, you can run the following command in folder `/app/v2ray-nginx-docker` to start the V2Ray server: `docker-compose up -d`. The `-d` option is to tell the programme to run in the background.
Run this command to check the running containers: `docker ps`.
To access to Traefik Dashboardhttps://traefik.example.com
To visit the camouflaged websitehttps://myapp.example.com
## Client configuration
Download the Windows client V2RayN, run it and click the menu: server - add [VMess] server. Please set the values according to the below figure:
![v2ray配置](https://github.com/alphacodinghub/v2ray/blob/master/images/v2rayn.png)
> **References**
- [Official Project V Website](https://www.v2ray.com/)
- [新白话文教程-V2Ray 配置指南](https://guide.v2fly.org/)
- <a href="https://github.com/v2fly/docker">Official Dockerfile</a>
- https://github.com/v2ray/ext
- https://toutyrater.github.io/app/docker-deploy-v2ray.html
- <a href="https://vimcaw.github.io/blog/2018/03/12/Shadowsocks(R)%E8%AE%BE%E7%BD%AE%EF%BC%9A%E7%B3%BB%E7%BB%9F%E4%BB%A3%E7%90%86%E6%A8%A1%E5%BC%8F%E3%80%81PAC%E3%80%81%E4%BB%A3%E7%90%86%E8%A7%84%E5%88%99/">SSR proxy settings - a great explaination</a>
+83
View File
@@ -0,0 +1,83 @@
# v2ray websocks tls + web all-in-one Docker
<a href="https://github.com/alphacodinghub/v2ray-docker/"><img src="https://img.shields.io/badge/Docker-v2ray-4BC51D.svg?style=flat"></a>
![](https://img.shields.io/badge/language-Web-orange.svg)
![](https://img.shields.io/badge/platform-Docker-lightgrey.svg)[![](https://img.shields.io/badge/Traefik-v2.x-blue.svg)](https://containo.us/traefik/)
![](https://img.shields.io/badge/license-MIT-000000.svg)
## Traefik 快速部署 V2RAY
- Docker 镜像基于 v2ray 官方最新版本,并集成 Nginx 服务器和一个简易网站
- 使用 Traefik 反向代理进行部署,操作简单,系统稳定
- Traefik 自动管理 Let's Encrypt,自动申请 ssl 证书,证书过期前自动更新
- 集成了一个简易伪装网站,缺省跳转至百度;也可以作为正式网站使用,只要将网站内容放到指定目录即可
- 可以定制 v2ray 参数,只要在.env 中按照模板设置相应参数即可,无需修改 docker-compose.yml
- 可以定制的 v2ray 参数包括:域名、UUID、监听端口、伪装路径等
## 服务器安装和配置步骤
### 1. 准备虚拟主机
- 申请虚拟主机,安装最新的 Docker 引擎和 git 工具。
- 申请一个域名,例如 `example.com`
- 选择一个名字作为`v2ray`应用的名称,例如`myapp`,那么`https://myapp.example.com`就是那个伪装的网站入口。
- 配置域名服务器,将`myapp.example.com`指向上一步申请的虚拟主机的 IP 地址。
### 2. 将本项目克隆到虚拟机相应目录,例如 /app/v2ray-nginx-docker
```script class:"lineNo"
- mkdir /app
- cd /app
- git clone https://github.com/alphacodinghub/v2ray-nginx-docker.git
- cd v2ray-nginx-docker
```
### 3. 配置参数(服务器)
紧接着修改`.env`文件,设定相关参数,以下三个参数必须设置:`APP_NAME`(第一步中选定的 v2ray 应用名称),`APP_DOMAIN`(第一步中申请的域名)`ACME_EMAIL`(你的 Email 地址,Let's Engcrypt 申请和更新证书的时候需要),其它参数都可以使用缺省参数,甚至可以从`.env`文件中去掉,`docker-compose.yml`中设置了缺省参数,可以打开查看。设置好的`.env`文件看起来这样:
```env
APP_NAME=myapp
APP_DOMAIN=example.com
ACME_EMAIL=myemail@example.com
LISTENING_PORT=3033
CLIENT_ID=2e5762cc-20d2-42b1-b0ad-cbe55dc5fa35
CLIENT_ALTERID=64
CLIENT_WSPATH=/allproducts
```
#### 上述配置中
```
- LISTENING_PORT: 是v2ray服务的监听端口
- CLIENT_ID: 是UUID,必须按规定的格式设置,v2ray用UUID加密传输,可以使用在线工具(https://www.uuidgenerator.net/)生成UUID
- CLIENT_ALTERID: 是`alterid`,为了进一步防止被探测,一个用户可以在主 UUID 的基础上,再额外生成多个 ID。这里只需要指定额UUUU ID 的数量,推荐值为 4。不指定的话,默认值是 0。最大值 65535。客户端也有对应的设置,客户端的这个值不能超过服务器端所指定的值
- CLIENT_WSPATH: 设置的伪装路径,客户端的配置要和服务器端的一致
- 如上配置的伪装网站为`https://myapp.example.com`,完整的v2ray伪装路径是`myapp.example.com/allproducts`
```
### 4. 伪装网站的配置
缺省情况下访问伪装网站`https://myapp.example.com`时会跳转至百度。可以将所需伪装成的网站拷贝至目录`./conf/html`下替换原有文件即可。如果直接访问伪装路径`https://myapp.example.com/allproducts`则会返回`Bad Request`。
### 5. 启动服务器
按上述步骤配置以后,在目录`/app/v2ray-nginx-docker`下运行下述命令即可: `docker-compose up -d`,其中参数`-d`表示在后台运行。查看启动的容器用这个命令:
`docker ps`。至此,服务器端的部署已经完成。
访问 Traefik Dashboardhttps://traefik.example.com
访问伪装网站:https://myapp.example.com
## 客户端配置
下载 Windows 客户端 V2RayN。
打开软件,依次点击:服务器 - 添加[VMess]服务器,按下图配置参数:
![v2ray配置](https://github.com/alphacodinghub/v2ray/blob/master/images/v2rayn.png)
> **参考资料:**
- [官方 Project V 网站](https://www.v2ray.com/)
- [新白话文教程-V2Ray 配置指南](https://guide.v2fly.org/)
- <a href="https://github.com/v2fly/docker">Official Dockerfile</a>
- https://github.com/v2ray/ext
+10
View File
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<title>HTML Meta Tag</title>
<meta http-equiv="refresh" content="0; url=https://www.baidu.com" />
</head>
<body>
<h1>Welcome to Baidu world!</h1>
</body>
</html>
+10
View File
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<title>HTML Meta Tag</title>
<meta http-equiv="refresh" content="0; url=https://www.baidu.com" />
</head>
<body>
<h1>Welcome to Baidu world!</h1>
</body>
</html>
-2
View File
@@ -1,6 +1,4 @@
#!/bin/bash
set -ex
TAG="4.23"
docker build -t alphacodinghub/v2ray-nginx:$TAG .
docker build -t alphacodinghub/v2ray-nginx:latest .
+14 -6
View File
@@ -5,7 +5,7 @@ services:
#### Traefik Proxy Setup #####
###############################################
traefik:
image: traefik:v2.2
image: traefik:v2.2.1
restart: always
container_name: traefik
ports:
@@ -18,11 +18,10 @@ services:
- --api.dashboard=true # <== Enabling the dashboard to view services, middlewares, routers, etc...
- --api.debug=true # <== Enabling additional endpoints for debugging and profiling
## Log Settings (options: ERROR, DEBUG, PANIC, FATAL, WARN, INFO) - https://docs.traefik.io/observability/logs/ ##
- --log.level=WARN # <== Setting the level of the logs from traefik
- --log.level=DEBUG # <== Setting the level of the logs from traefik
## Provider Settings - https://docs.traefik.io/providers/docker/#provider-configuration ##
- --providers.docker=true # <== Enabling docker as the provider for traefik
- --providers.docker.exposedbydefault=false # <== Don't expose every container to traefik, only expose enabled ones
- --providers.docker.network=web # <== Operate on the docker network named web on frontend
## Entrypoints Settings - https://docs.traefik.io/routing/entrypoints/#configuration ##
- --entrypoints.web.address=:80 # <== Defining an entrypoint for port :80 named web
- --entrypoints.web-secured.address=:443 # <== Defining an entrypoint for https on port :443 named web-secured
@@ -31,8 +30,8 @@ services:
- --certificatesresolvers.mytlschallenge.acme.email=${ACME_EMAIL} # <== Setting email for certs
- --certificatesresolvers.mytlschallenge.acme.storage=/letsencrypt/acme.json # <== Defining acme file to store cert information
volumes:
- ./config/traefik/letsencrypt:/letsencrypt # <== Volume for certs (TLS)
- /var/run/docker.sock:/var/run/docker.sock # <== Volume for docker admin
- ./conf/traefik/letsencrypt:/letsencrypt # <== Volume for certs (TLS)
- /var/run/docker.sock:/var/run/docker.sock # <== Volume for docker admin. Don't change it!
labels:
#### Labels define the behavior and rules of the traefik proxy for this container ####
traefik.enable: true # <== Enable traefik on itself to view dashboard and assign subdomain to view it
@@ -57,11 +56,20 @@ services:
##############################################
v2ray:
image: alphacodinghub/v2ray-nginx
ports:
- ${LISTENING_PORT:-3003}
container_name: v2ray
restart: always
environment:
LISTENING_PORT: ${LISTENING_PORT:-3003}
CLIENT_ID: ${CLIENT_ID:-2e5762cc-20d2-42b1-b0ad-cbe55dc5fa35}
CLIENT_ALTERID: ${CLIENT_ALTERID:-64}
CLIENT_WSPATH: ${CLIENT_WSPATH:-/allproducts}
volumes:
- ./conf/html:/var/www/html
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.v2ray.rule: Host(`$(APP_NAME).${APP_DOMAIN}`) # <== Your Domain Name for the https rule
traefik.http.routers.v2ray.rule: Host(`${APP_NAME}.${APP_DOMAIN}`) # && PathPrefix(`${CLIENT_WSPATH:-/allproducts}`) # <== Your Domain Name for the https rule
traefik.http.routers.v2ray.entrypoints: web-secured # <== Defining entrypoint for https, **ref: line 31
traefik.http.routers.v2ray.tls.certresolver: mytlschallenge # <== Defining certsresolvers for https
+4 -4
View File
@@ -5,8 +5,8 @@
"loglevel": "debug"
},
"inbound": {
"port": 30003,
"listen":"127.0.0.1",
"port": LISTENING_PORT,
"listen": "127.0.0.1",
"protocol": "vmess",
"settings": {
"clients": [
@@ -16,8 +16,8 @@
}
]
},
"streamSettings":{
"network":"ws",
"streamSettings": {
"network": "ws",
"wsSettings": {
"path": "CLIENT_WSPATH"
}
+1 -1
View File
@@ -9,7 +9,7 @@ server {
location CLIENT_WSPATH {
proxy_redirect off;
proxy_pass http://127.0.0.1:30003;
proxy_pass http://127.0.0.1:LISTENING_PORT;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
+2
View File
@@ -1,6 +1,8 @@
#!/bin/sh
sed -i "s/LISTENING_PORT/$LISTENING_PORT/g" /etc/v2ray/config.json
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
sed -i "s/LISTENING_PORT/$LISTENING_PORT/g" /etc/nginx/conf.d/default.conf
exec "$@"
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB