0%

nginx-proxy 多镜像下使用v2ray

nginx-proxy 多镜像下使用v2ray

单一 docker-compose.yml 指路

多个docker-compose.yml 时,上面的方法就不在适用了。

主要原因是nginx-proxy找不到指定的服务器。

指定服务器名称,并加入到相同网络可破

nginx-proxy 加 letsencrypt

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
version: '2'

services:
nginx-proxy:
image: jwilder/nginx-proxy:latest
restart: always
ports:
- "80:80"
- "443:443"
volumes:
- /path/to/certs:/etc/nginx/certs:ro
- $PWD/vhost.d:/etc/nginx/vhost.d:rw
- /usr/share/nginx/html
- /var/run/docker.sock:/tmp/docker.sock:ro
labels:
- "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy"
network_mode: "bridge"
letsencrypt-nginx-proxy-companion:
image: jrcs/letsencrypt-nginx-proxy-companion:latest
restart: always
volumes:
- /path/to/certs:/etc/nginx/certs:rw
- /var/run/docker.sock:/var/run/docker.sock:ro
volumes_from:
- nginx-proxy
network_mode: "bridge"

v2ray 独立

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
version: '2'

services:
v2ray:
image: v2ray/official
container_name: v2ray
restart: always
expose:
- "1234"
volumes:
- $PWD/v2ray:/etc/v2ray
- $PWD/v2ray/config.json:/etc/v2ray/config.json:ro
environment:
- VIRTUAL_HOST=v2ray

network_mode: "bridge"

web1:
image: nginx:latest
restart: always
expose:
- "80"
volumes:
- $PWD/html:/usr/share/nginx/html:ro
environment:
- VIRTUAL_HOST=your.domain.name
- VIRTUAL_PORT=80
- LETSENCRYPT_HOST=your.domain.name
- [email protected]
network_mode: "bridge"

your.domain.name_location

直接指定服务器不需端口

1
2
3
4
5
6
7
8
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
if ($http_upgrade = "websocket" ) {
proxy_pass http://v2ray;
}

重要信息

别忘了创建config.json文件!😁

以上 长久的问题解决了