first-commit

This commit is contained in:
zeaslity
2023-05-15 16:49:09 +08:00
commit 06cba6ca3c
816 changed files with 157018 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
# reference
### https://www.dejavu.moe/posts/selfhosted-bitwarden-with-cloudflare-tunnel/

View File

@@ -0,0 +1,54 @@
IP_HEADER=none
WEBSOCKET_ENABLED=true
WEBSOCKET_ADDRESS=0.0.0.0
WEBSOCKET_PORT=3012
SENDS_ALLOWED=true
# 启用紧急访问
EMERGENCY_ACCESS_ALLOWED=true
# 日志等级
LOG_LEVEL=warn
# 注册需要验证?
SIGNUPS_VERIFY=true
SIGNUPS_VERIFY_RESEND_TIME=3600
SIGNUPS_VERIFY_RESEND_LIMIT=3
# 允许注册的域名白名单(你的邮箱域名)
SIGNUPS_DOMAINS_WHITELIST=107421.xyz
# 允许创建组织的用户邮箱
ORG_CREATION_USERS=you@107421.xyz
# 使用 openssl rand -base64 48 命令快速生成管理员令牌
ADMIN_TOKEN=WnzCmaUPhFsN5jUphoazxw4hlh2cfwjlUPPKJOXxYdLAApxuoFiCIgIjUO8HbaY7
# 允许邀请?
INVITATIONS_ALLOWED=true
# 邀请名称
INVITATION_ORG_NAME=Vault-Warden
# 邀请失效时间(时)
INVITATION_EXPIRATION_HOURS=12
# 密码提示?
SHOW_PASSWORD_HINT=false
# Vaultwarden 域名
DOMAIN=https://vault-warden.107421.xyz
# 替换您的 Yubikey API 信息(没有请注释掉)
#YUBICO_CLIENT_ID=87654
#YUBICO_SECRET_KEY=Sd1yGCsWonKyDAkyhObC1khs2QDJQYo1arrfDmg=
# YUBICO_SERVER=http://107421.xyz/wsapi/2.0/verify
# 设置您的 SMTP 发送邮箱信息
#SMTP_HOST=smtp.xxx.com
#SMTP_FROM=warden@107421.xyz
#SMTP_FROM_NAME=Vaultwarden Service
# 根据邮箱修改
#SMTP_SECURITY=force_tls
# SMTP 端口
#SMTP_PORT=465
#SMTP_USERNAME=warden@107421.xyz
# 密码用 '' 包围起来
#SMTP_PASSWORD='Y6qMP7LVgx+JOzYa3kKbOq8q'
#SMTP_TIMEOUT=15

View File

@@ -0,0 +1,16 @@
version: '3.3'
services:
vaultwarden:
image: vaultwarden/server:alpine
container_name: vault-warden
restart: always
environment:
- TZ=Asia/Shanghai
ports:
- 1314:80 # Vaultwarden 映射端口
- 3012:3012 # Websocket 映射端口
volumes:
- '/data/vault-warden/persist-data:/data'
env_file:
- /root/app-install/vault-warden/vault.env # 环境变量路径

View File

@@ -0,0 +1,143 @@
version: "3.3"
services:
reverse-proxy:
image: traefik:v2.3
command:
- --log.level=WARN
#- --api.insecure=true
- --providers.docker
- --entryPoints.web.address=:80
- --entrypoints.web.http.redirections.entryPoint.to=websecure
- --entrypoints.web.http.redirections.entryPoint.scheme=https
- --entryPoints.websecure.address=:443
- --certificatesresolvers.myresolver.acme.email=tom@tcweb.org
- --certificatesresolvers.myresolver.acme.storage=/acme.json
# used during the challenge
- --certificatesresolvers.myresolver.acme.httpchallenge.entrypoint=web
ports:
- "80:80"
- "443:443"
# The Web UI (enabled by --api.insecure=true)
#- "8080:8080"
depends_on:
- nextcloud-front
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./acme.json:/acme.json
restart: unless-stopped
networks:
nextcloud:
aliases:
- traefik
nextcloud-front:
image: nginx:latest
depends_on:
- nextcloud-app
restart: unless-stopped
volumes:
- ./nextcloud-data/:/var/www/html:ro
- ./nginx.conf:/etc/nginx/conf.d/nextcloud.conf:ro
labels:
- "traefik.http.routers.front.rule=Host(`cloud.${DOMAIN}`)"
- "traefik.http.routers.front.entryPoints=web,traefik"
- "traefik.http.services.front.loadbalancer.server.port=80"
- "traefik.http.routers.front-ssl.rule=Host(`cloud.${DOMAIN}`)"
- "traefik.http.routers.front-ssl.entryPoints=websecure"
- "traefik.http.routers.front-ssl.tls=true"
- "traefik.http.routers.front-ssl.service=front"
- "traefik.http.routers.front-ssl.tls.certresolver=myresolver"
networks:
nextcloud:
aliases:
- front
collabora:
image: collabora/code
restart: unless-stopped
labels:
- "traefik.http.routers.collabora.rule=Host(`office.${DOMAIN}`)"
- "traefik.http.routers.collabora.entryPoints=web,traefik"
- "traefik.http.services.collabora.loadbalancer.server.port=9980"
- "traefik.http.routers.collabora-ssl.rule=Host(`office.${DOMAIN}`)"
- "traefik.http.routers.collabora-ssl.entryPoints=websecure"
- "traefik.http.routers.collabora-ssl.tls=true"
- "traefik.http.routers.collabora-ssl.service=collabora"
- "traefik.http.routers.collabora-ssl.tls.certresolver=myresolver"
- "traefik.wss.protocol=https"
environment:
extra_params: "--o:ssl.enable=true"
domain: cloud\\.tcweb\\.org
networks:
nextcloud:
aliases:
- collabora
nextcloud-app:
image: nextcloud:22-fpm
environment:
MYSQL_USER: nextcloud
MYSQL_PASSWORD: "${MYSQL_PASSWORD}"
MYSQL_DATABASE: nextcloud
MYSQL_HOST: mysql
REDIS_HOST: redis
PHP_MEMORY_LIMIT: 4096M
depends_on:
- nextcloud-db
- nextcloud-redis
restart: unless-stopped
volumes:
- ./nextcloud-data/:/var/www/html
networks:
nextcloud:
aliases:
- app
nextcloud-cron:
image: nextcloud:22-fpm
environment:
MYSQL_USER: nextcloud
MYSQL_PASSWORD: "${MYSQL_PASSWORD}"
MYSQL_DATABASE: nextcloud
MYSQL_HOST: mysql
REDIS_HOST: redis
PHP_MEMORY_LIMIT: 4096M
entrypoint: /cron.sh
depends_on:
- nextcloud-db
- nextcloud-redis
restart: unless-stopped
volumes:
- ./nextcloud-data/:/var/www/html
networks:
nextcloud:
aliases:
- cron
nextcloud-redis:
image: redis:latest
restart: unless-stopped
networks:
nextcloud:
aliases:
- redis
nextcloud-db:
image: mariadb:latest
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: "${MYSQL_ROOT_PASSWORD}"
MYSQL_PASSWORD: "${MYSQL_PASSWORD}"
MYSQL_DATABASE: nextcloud
MYSQL_USER: nextcloud
command: --innodb_read_only_compressed=OFF
volumes:
- ./nextcloud-db:/var/lib/mysql
networks:
nextcloud:
aliases:
- mysql
# Custom network so all services can communicate using a FQDN
networks:
nextcloud:

View File

@@ -0,0 +1,3 @@
DOMAIN=cloud.tcweb.org
MYSQL_PASSWORD=
MYSQL_ROOT_PASSWORD=

View File

@@ -0,0 +1,16 @@
#!/bin/bash
function generatePassword() {
openssl rand -hex 16
}
MYSQL_PASSWORD=$(generatePassword)
MYSQL_ROOT_PASSWORD=$(generatePassword)
cat "$(dirname "$0")/env.sample" | sed \
-e "s#MYSQL_PASSWORD=.*#MYSQL_PASSWORD=${MYSQL_PASSWORD}#g" \
-e "s#MYSQL_ROOT_PASSWORD=.*#MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}#g" \
"$(dirname "$0")/.env"
touch "$(dirname "$0")/acme.json"
chmod 600 "$(dirname "$0")/acme.json"

View File

@@ -0,0 +1,141 @@
upstream php-handler {
server app:9000;
}
server {
listen 80;
server_name cloud.tcweb.org;
# Add headers to serve security related headers
# Before enabling Strict-Transport-Security headers please read into this
# topic first.
#add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;" always;
#
# WARNING: Only add the preload option once you read about
# the consequences in https://hstspreload.org/. This option
# will add the domain to a hardcoded list that is shipped
# in all major browsers and getting removed from this list
# could take several months.
add_header Referrer-Policy "no-referrer" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-Download-Options "noopen" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Permitted-Cross-Domain-Policies "none" always;
add_header X-Robots-Tag "none" always;
add_header X-XSS-Protection "1; mode=block" always;
# Remove X-Powered-By, which is an information leak
fastcgi_hide_header X-Powered-By;
# Path to the root of your installation
root /var/www/html;
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
# The following 2 rules are only needed for the user_webfinger app.
# Uncomment it if you're planning to use this app.
#rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
#rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last;
# The following rule is only needed for the Social app.
# Uncomment it if you're planning to use this app.
#rewrite ^/.well-known/webfinger /public.php?service=webfinger last;
location = /.well-known/carddav {
return 301 $scheme://$host:$server_port/remote.php/dav;
}
location = /.well-known/caldav {
return 301 $scheme://$host:$server_port/remote.php/dav;
}
# set max upload size
client_max_body_size 10G;
fastcgi_buffers 64 4K;
# Enable gzip but do not remove ETag headers
gzip on;
gzip_vary on;
gzip_comp_level 4;
gzip_min_length 256;
gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy;
# Uncomment if your server is build with the ngx_pagespeed module
# This module is currently not supported.
#pagespeed off;
location / {
rewrite ^ /index.php;
}
location ~ ^\/(?:build|tests|config|lib|3rdparty|templates|data)\/ {
deny all;
}
location ~ ^\/(?:\.|autotest|occ|issue|indie|db_|console) {
deny all;
}
location ~ ^\/(?:index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|oc[ms]-provider\/.+)\.php(?:$|\/) {
fastcgi_split_path_info ^(.+?\.php)(\/.*|)$;
set $path_info $fastcgi_path_info;
try_files $fastcgi_script_name =404;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $path_info;
# fastcgi_param HTTPS on;
# Avoid sending the security headers twice
fastcgi_param modHeadersAvailable true;
# Enable pretty urls
fastcgi_param front_controller_active true;
fastcgi_pass php-handler;
fastcgi_intercept_errors on;
fastcgi_request_buffering off;
}
location ~ ^\/(?:updater|oc[ms]-provider)(?:$|\/) {
try_files $uri/ =404;
index index.php;
}
# Adding the cache control header for js, css and map files
# Make sure it is BELOW the PHP block
location ~ \.(?:css|js|woff2?|svg|gif|map)$ {
try_files $uri /index.php$request_uri;
add_header Cache-Control "public, max-age=15778463";
# Add headers to serve security related headers (It is intended to
# have those duplicated to the ones above)
# Before enabling Strict-Transport-Security headers please read into
# this topic first.
#add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;" always;
#
# WARNING: Only add the preload option once you read about
# the consequences in https://hstspreload.org/. This option
# will add the domain to a hardcoded list that is shipped
# in all major browsers and getting removed from this list
# could take several months.
add_header Referrer-Policy "no-referrer" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-Download-Options "noopen" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Permitted-Cross-Domain-Policies "none" always;
add_header X-Robots-Tag "none" always;
add_header X-XSS-Protection "1; mode=block" always;
# Optional: Don't log access to assets
access_log off;
}
location ~ \.(?:png|html|ttf|ico|jpg|jpeg|bcmap|mp4|webm)$ {
try_files $uri /index.php$request_uri;
# Optional: Don't log access to other assets
access_log off;
}
}

View File

@@ -0,0 +1,40 @@
server {
server_name book.107421.xyz;
listen 80 ;
return 301 https://book.107421.xyz$request_uri;
}
server {
listen 443 ssl;
server_name book.107421.xyz;
ssl_certificate /etc/nginx/conf.d/ssl_key/book.107421.xyz.cert.pem;
ssl_certificate_key /etc/nginx/conf.d/ssl_key/book.107421.xyz.key.pem;
ssl_session_timeout 1d;
ssl_session_cache shared:MozSSL:10m;
ssl_session_tickets off;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
ssl_prefer_server_ciphers off;
location / {
access_log /var/log/nginx/access.log main;
client_max_body_size 5120m;
client_body_buffer_size 5120m;
client_body_timeout 6000s;
proxy_send_timeout 10000s;
proxy_read_timeout 10000s;
proxy_connect_timeout 600s;
proxy_max_temp_file_size 5120m;
proxy_request_buffering on;
proxy_buffering off;
proxy_buffer_size 4k;
proxy_buffers 4 12k;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_pass http://localhost:8091;
}
}

View File

@@ -0,0 +1,13 @@
#!/bin/bash
export DOMAIN_NAME=book.107421.xyz
export CF_Token="oXJRP5XI8Zhipa_PtYtB_jy6qWL0I9BosrJEYE8p"
export CF_Account_ID="dfaadeb83406ef5ad35da02617af9191"
export CF_Zone_ID="511894a4f1357feb905e974e16241ebb"
acme.sh --issue --dns dns_cf -d ${DOMAIN_NAME} --keylength ec-256
acme.sh --install-cert -d ${DOMAIN_NAME} --ecc \
--key-file /etc/nginx/conf.d/ssl_key/${DOMAIN_NAME}.key.pem \
--fullchain-file /etc/nginx/conf.d/ssl_key/${DOMAIN_NAME}.cert.pem \
--reloadcmd "systemctl restart nginx --force"

View File

@@ -0,0 +1,26 @@
#!/bin/bash
cat >/root/app-install/komga/update-komga.sh<<EOF
#!/bin/bash
docker container stop komga
sleep 3
docker container rm komga
docker image rmi gotson/komga:latest
docker run \
--name=komga \
-d \
-p 8091:8080 \
-v /data/komga/config:/config \
-v /data/komga/data:/data \
-v /data/nextcloud/data/zeaslity/files/MasterLoad/Java/komga-book:/netcloud-java-book \
--restart unless-stopped \
gotson/komga:latest
EOF
docker container stop komga && docker container rm komga