initial commit
This commit is contained in:
parent
47879e4f24
commit
b71626e5f8
|
@ -0,0 +1,43 @@
|
||||||
|
{
|
||||||
|
"inbounds": [
|
||||||
|
{
|
||||||
|
"port": 1080,
|
||||||
|
"listen": "127.0.0.1",
|
||||||
|
"protocol": "socks",
|
||||||
|
"sniffing": {
|
||||||
|
"enabled": true,
|
||||||
|
"destOverride": ["http", "tls"]
|
||||||
|
},
|
||||||
|
"settings": {
|
||||||
|
"auth": "noauth",
|
||||||
|
"udp": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"outbounds": [
|
||||||
|
{
|
||||||
|
"protocol": "vmess",
|
||||||
|
"settings": {
|
||||||
|
"vnext": [
|
||||||
|
{
|
||||||
|
"address": "nocturne.quacker.net",
|
||||||
|
"port": 443,
|
||||||
|
"users": [
|
||||||
|
{
|
||||||
|
"id": "{{ uuid }}",
|
||||||
|
"alterId": 64
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"streamSettings": {
|
||||||
|
"network": "ws",
|
||||||
|
"security": "tls",
|
||||||
|
"wsSettings": {
|
||||||
|
"path": "/{{ path }}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
version: '3.4'
|
||||||
|
|
||||||
|
networks:
|
||||||
|
br0:
|
||||||
|
external: false
|
||||||
|
|
||||||
|
services:
|
||||||
|
nginx:
|
||||||
|
container_name: nginx
|
||||||
|
image: linuxserver/letsencrypt
|
||||||
|
restart: always
|
||||||
|
cap_add:
|
||||||
|
- NET_ADMIN
|
||||||
|
networks:
|
||||||
|
- br0
|
||||||
|
environment:
|
||||||
|
- PUID={{ uid }}
|
||||||
|
- PGID={{ gid }}
|
||||||
|
- TZ=US/Eastern
|
||||||
|
- URL={{ domain }}
|
||||||
|
- SUBDOMAINS={{ subdomain }}
|
||||||
|
- VALIDATION=http
|
||||||
|
- EMAIL={{ email }}
|
||||||
|
- DHLEVEL=2048
|
||||||
|
- ONLY_SUBDOMAINS={{ only_sub }}
|
||||||
|
- STAGING=false
|
||||||
|
ports:
|
||||||
|
- 80:80
|
||||||
|
- 443:443
|
||||||
|
volumes:
|
||||||
|
- ./nginx:/config
|
||||||
|
|
||||||
|
v2ray:
|
||||||
|
container_name: v2ray
|
||||||
|
image: v2ray/official
|
||||||
|
restart: always
|
||||||
|
networks:
|
||||||
|
- br0
|
||||||
|
command: ["v2ray","-config=/etc/v2ray/config.json"]
|
||||||
|
volumes:
|
||||||
|
- ./v2ray:/etc/v2ray
|
|
@ -0,0 +1,34 @@
|
||||||
|
# redirect all traffic to https
|
||||||
|
server {
|
||||||
|
listen 80 default_server;
|
||||||
|
listen [::]:80 default_server;
|
||||||
|
server_name _;
|
||||||
|
return 301 https://$host$request_uri;
|
||||||
|
}
|
||||||
|
|
||||||
|
# main server block
|
||||||
|
server {
|
||||||
|
listen 443 ssl http2 default_server;
|
||||||
|
listen [::]:443 ssl http2 default_server;
|
||||||
|
|
||||||
|
root /config/www;
|
||||||
|
index index.html index.htm index.php;
|
||||||
|
|
||||||
|
# all ssl related config moved to ssl.conf
|
||||||
|
include /config/nginx/ssl.conf;
|
||||||
|
|
||||||
|
server_name {{server_name}};
|
||||||
|
location /{{ path }} {
|
||||||
|
proxy_redirect off;
|
||||||
|
proxy_pass http://v2ray:8080;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection "upgrade";
|
||||||
|
proxy_set_header Host $http_host;
|
||||||
|
|
||||||
|
# Show realip in v2ray access.log
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,116 @@
|
||||||
|
import getopt
|
||||||
|
import sys
|
||||||
|
import uuid
|
||||||
|
import pwd
|
||||||
|
import jinja2
|
||||||
|
import random
|
||||||
|
import os
|
||||||
|
import string
|
||||||
|
|
||||||
|
def randomString(stringLength=16):
|
||||||
|
letters = string.ascii_lowercase
|
||||||
|
return ''.join(random.choice(letters) for i in range(stringLength))
|
||||||
|
|
||||||
|
def usage():
|
||||||
|
print("Usage: python setup.py [options]\n\
|
||||||
|
Options:\n\
|
||||||
|
-h : show usage\n\
|
||||||
|
-d domain : your domain - mydomain.tld\n\
|
||||||
|
[-s subdomain] : your subdomain. Optional.\n\
|
||||||
|
[-e email] : your email. Optional.\n")
|
||||||
|
|
||||||
|
def main():
|
||||||
|
email = None
|
||||||
|
subdomain = None
|
||||||
|
domain = None
|
||||||
|
uid = os.getuid()
|
||||||
|
gid = os.getgid()
|
||||||
|
v_uuid = uuid.uuid4()
|
||||||
|
v_path = randomString()
|
||||||
|
|
||||||
|
try:
|
||||||
|
opts , args = getopt.getopt(sys.argv[1:], "hd:s:e:")
|
||||||
|
except getopt.GetoptError as err:
|
||||||
|
print(str(err))
|
||||||
|
usage()
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
for o, a in opts:
|
||||||
|
if o == "-h":
|
||||||
|
usage()
|
||||||
|
sys.exit(0)
|
||||||
|
elif o == "-d":
|
||||||
|
if domain != None:
|
||||||
|
print("Can specify maximum ONE domain.")
|
||||||
|
sys.exit(1)
|
||||||
|
else:
|
||||||
|
domain = a
|
||||||
|
elif o == "-s":
|
||||||
|
if subdomain != None:
|
||||||
|
print("Can specify maximum ONE subdomain.")
|
||||||
|
sys.exit(1)
|
||||||
|
else:
|
||||||
|
subdomain = a
|
||||||
|
elif o == "-e":
|
||||||
|
if email != None:
|
||||||
|
print("Can specify maximum ONE email.")
|
||||||
|
else:
|
||||||
|
email = a
|
||||||
|
|
||||||
|
if domain == None:
|
||||||
|
print("Must specify a domain.")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
server_name = None
|
||||||
|
if subdomain == None:
|
||||||
|
server_name = domain
|
||||||
|
else:
|
||||||
|
server_name = subdomain + "." + domain
|
||||||
|
|
||||||
|
# process docker-compose
|
||||||
|
with open("docker-compose.yml", "r") as file:
|
||||||
|
template = jinja2.Template(file.read())
|
||||||
|
|
||||||
|
output = template.render(uid = uid, gid = gid, domain = domain, \
|
||||||
|
subdomain = (subdomain if subdomain != None else ""), \
|
||||||
|
only_sub = ("true" if subdomain != None else "false"), \
|
||||||
|
email = ("dummy@dummy.com" if email == None else email))
|
||||||
|
|
||||||
|
with open("docker-compose.yml", "w") as file:
|
||||||
|
file.write(output)
|
||||||
|
|
||||||
|
# process v2ray/config
|
||||||
|
with open("v2ray/config.json", "r") as file:
|
||||||
|
template = jinja2.Template(file.read())
|
||||||
|
|
||||||
|
output = template.render(uuid = v_uuid, path = v_path)
|
||||||
|
|
||||||
|
with open("v2ray/config.json", "w") as file:
|
||||||
|
file.write(output)
|
||||||
|
|
||||||
|
# process nginx/nginx/site-confs/default
|
||||||
|
with open("nginx/nginx/site-confs/default", "r") as file:
|
||||||
|
template = jinja2.Template(file.read())
|
||||||
|
|
||||||
|
output = template.render(server_name = server_name, path = v_path)
|
||||||
|
|
||||||
|
with open("nginx/nginx/site-confs/default", "w") as file:
|
||||||
|
file.write(output)
|
||||||
|
|
||||||
|
# process client.conf
|
||||||
|
with open("client.conf", "r") as file:
|
||||||
|
template = jinja2.Template(file.read())
|
||||||
|
|
||||||
|
output = template.render(uuid = v_uuid, path = v_path)
|
||||||
|
|
||||||
|
with open("client.conf", "w") as file:
|
||||||
|
file.write(output)
|
||||||
|
|
||||||
|
print("Processed all files. The detailed client config is written to client.conf.\n\
|
||||||
|
Summary:\n\
|
||||||
|
Server Address: " + server_name + "\n\
|
||||||
|
Path: " + v_path + "\n\
|
||||||
|
UUID: " + v_uuid + "\n\n\
|
||||||
|
Please run docker-compose up -d to start the service.")
|
||||||
|
|
||||||
|
main()
|
|
@ -0,0 +1,29 @@
|
||||||
|
{
|
||||||
|
"inbounds": [
|
||||||
|
{
|
||||||
|
"port": 8080,
|
||||||
|
"listen":"0.0.0.0",
|
||||||
|
"protocol": "vmess",
|
||||||
|
"settings": {
|
||||||
|
"clients": [
|
||||||
|
{
|
||||||
|
"id": "{{ uuid }}",
|
||||||
|
"alterId": 64
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"streamSettings": {
|
||||||
|
"network": "ws",
|
||||||
|
"wsSettings": {
|
||||||
|
"path": "/{{ path }}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"outbounds": [
|
||||||
|
{
|
||||||
|
"protocol": "freedom",
|
||||||
|
"settings": {}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
Loading…
Reference in New Issue