├── .dockerignore ├── .github ├── FUNDING.yml └── workflows │ └── docker-image.yml ├── .gitignore ├── Dockerfile ├── LICENSE ├── README.md ├── etc ├── nginx │ └── conf │ │ └── nginx.template.conf └── webtor │ ├── common.env │ └── torrent-http-proxy │ └── config.yaml └── s6-overlay ├── s6-rc.d ├── content-transcoder │ ├── dependencies.d │ │ └── base │ ├── run │ └── type ├── external-proxy │ ├── dependencies.d │ │ └── base │ ├── run │ └── type ├── generate-api-key-and-secret │ ├── dependencies.d │ │ └── base │ ├── type │ └── up ├── magnet2torrent │ ├── dependencies.d │ │ └── base │ ├── run │ └── type ├── nginx-vod │ ├── dependencies.d │ │ └── base │ ├── run │ └── type ├── redis │ ├── dependencies.d │ │ └── base │ ├── run │ └── type ├── rest-api │ ├── dependencies.d │ │ └── base │ ├── run │ └── type ├── srt2vtt │ ├── dependencies.d │ │ └── base │ ├── run │ └── type ├── torrent-archiver │ ├── dependencies.d │ │ └── base │ ├── run │ └── type ├── torrent-http-proxy │ ├── dependencies.d │ │ ├── base │ │ └── generate-api-key-and-secret │ ├── run │ └── type ├── torrent-store │ ├── dependencies.d │ │ └── base │ ├── run │ └── type ├── torrent-web-seeder-cleaner │ ├── dependencies.d │ │ └── base │ ├── run │ └── type ├── torrent-web-seeder │ ├── dependencies.d │ │ └── base │ ├── run │ └── type ├── user │ └── contents.d │ │ ├── content-transcoder │ │ ├── external-proxy │ │ ├── generate-api-key-and-secret │ │ ├── magnet2torrent │ │ ├── nginx-vod │ │ ├── redis │ │ ├── rest-api │ │ ├── srt2vtt │ │ ├── torrent-archiver │ │ ├── torrent-http-proxy │ │ ├── torrent-store │ │ ├── torrent-web-seeder │ │ ├── torrent-web-seeder-cleaner │ │ └── web-ui └── web-ui │ ├── dependencies.d │ ├── base │ └── generate-api-key-and-secret │ ├── run │ └── type └── scripts └── generate-api-key-and-secret /.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | .github 3 | .vscode 4 | .dockerignore 5 | *Dockerfile* 6 | README.md 7 | LICENSE 8 | .DS_Store -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: pavel_tatarskiy 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 13 | -------------------------------------------------------------------------------- /.github/workflows/docker-image.yml: -------------------------------------------------------------------------------- 1 | on: 2 | workflow_dispatch: 3 | push: 4 | # branches: 5 | # - 'main' 6 | tags: 7 | - 'v*' 8 | # pull_request: 9 | # branches: 10 | # - 'main' 11 | env: 12 | REGISTRY: ghcr.io 13 | IMAGE_NAME: ${{ github.repository }} 14 | 15 | jobs: 16 | docker: 17 | runs-on: ubuntu-latest 18 | steps: 19 | - 20 | name: Checkout 21 | uses: actions/checkout@v4 22 | - 23 | name: Docker meta 24 | id: meta 25 | uses: docker/metadata-action@v5 26 | with: 27 | images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} 28 | tags: | 29 | type=ref,event=branch 30 | type=ref,event=pr 31 | type=semver,pattern={{version}} 32 | type=semver,pattern={{major}}.{{minor}} 33 | type=sha 34 | - 35 | name: Login to DockerHub 36 | if: github.event_name != 'pull_request' 37 | uses: docker/login-action@v3 38 | with: 39 | registry: ${{ env.REGISTRY }} 40 | username: ${{ github.actor }} 41 | password: ${{ secrets.GITHUB_TOKEN }} 42 | - 43 | name: Build and push 44 | uses: docker/build-push-action@v6 45 | with: 46 | context: . 47 | push: ${{ github.event_name != 'pull_request' }} 48 | tags: ${{ steps.meta.outputs.tags }} 49 | labels: ${{ steps.meta.outputs.labels }} 50 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Binaries for programs and plugins 2 | *.exe 3 | *.exe~ 4 | *.dll 5 | *.so 6 | *.dylib 7 | 8 | # Test binary, build with `go test -c` 9 | *.test 10 | 11 | # Output of the go coverage tool, specifically when used with LiteIDE 12 | *.out 13 | *.db 14 | 15 | tmp 16 | 17 | .DS_Store 18 | 19 | .env 20 | 21 | .idea 22 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | ARG ALPINE_VER="3.21" 2 | ARG GOLANG_VER="1.24-alpine3.21" 3 | ARG NODE_VER="23-alpine3.20" 4 | ARG S6_OVERLAY_VER="3.2.0.2" 5 | ARG S6_VERBOSITY=1 6 | 7 | # Webtor services 8 | ARG TORRENT_STORE_COMMIT="v1.0.0" 9 | ARG MAGNET2TORRENT_COMMIT="v1.0.0" 10 | ARG EXTERNAL_PROXY_COMMIT="v1.0.0" 11 | ARG TORRENT_WEB_SEEDER_COMMIT="v1.0.0" 12 | ARG TORRENT_WEB_SEEDER_CLEANER_COMMIT="v1.0.0" 13 | ARG CONTENT_TRANSCODER_COMMIT="v1.0.0" 14 | ARG TORRENT_ARCHIVER_COMMIT="v1.0.0" 15 | ARG SRT2VTT_COMMIT="v1.0.0" 16 | ARG TORRENT_HTTP_PROXY_COMMIT="v1.0.0" 17 | ARG REST_API_COMMIT="v1.0.0" 18 | ARG WEB_UI_COMMIT="v2.0.2" 19 | 20 | # Nginx deps 21 | ARG NGINX_VERSION="1.26.2" 22 | ARG VOD_MODULE_COMMIT="26f06877b0f2a2336e59cda93a3de18d7b23a3e2" 23 | ARG SECURE_TOKEN_MODULE_COMMIT="24f7b99d9b665e11c92e585d6645ed6f45f7d310" 24 | 25 | FROM golang:$GOLANG_VER AS build-app 26 | 27 | RUN apk add --no-cache build-base git 28 | RUN git config --global http.version HTTP/1.1 29 | 30 | WORKDIR /app 31 | RUN mkdir "src" && mkdir "bin" 32 | 33 | FROM build-app AS build-torrent-store 34 | 35 | ARG TORRENT_STORE_COMMIT 36 | 37 | ENV CGO_ENABLED=0 GOOS=linux 38 | 39 | RUN echo $TORRENT_STORE_COMMIT > /app/bin/torrent-store.commit && \ 40 | git clone https://github.com/webtor-io/torrent-store /app/src/torrent-store && \ 41 | cd /app/src/torrent-store && \ 42 | git checkout $TORRENT_STORE_COMMIT && \ 43 | go build \ 44 | -ldflags '-w -s -X google.golang.org/protobuf/reflect/protoregistry.conflictPolicy=ignore' \ 45 | -a -installsuffix cgo -o /app/bin/torrent-store 46 | 47 | FROM build-app AS build-magnet2torrent 48 | 49 | ARG MAGNET2TORRENT_COMMIT 50 | 51 | ENV CGO_ENABLED=0 GOOS=linux 52 | 53 | RUN echo $MAGNET2TORRENT_COMMIT > /app/bin/magnet2torrent.commit && \ 54 | git clone https://github.com/webtor-io/magnet2torrent /app/src/magnet2torrent && \ 55 | cd /app/src/magnet2torrent/server && \ 56 | git checkout $MAGNET2TORRENT_COMMIT && \ 57 | go build \ 58 | -ldflags '-w -s -X google.golang.org/protobuf/reflect/protoregistry.conflictPolicy=ignore' \ 59 | -a -installsuffix cgo -o /app/bin/magnet2torrent 60 | 61 | FROM build-app AS build-external-proxy 62 | 63 | ARG EXTERNAL_PROXY_COMMIT 64 | 65 | ENV CGO_ENABLED=0 GOOS=linux 66 | 67 | RUN echo $EXTERNAL_PROXY_COMMIT > /app/bin/external-proxy.commit && \ 68 | git clone https://github.com/webtor-io/external-proxy /app/src/external-proxy && \ 69 | cd /app/src/external-proxy && \ 70 | git checkout $EXTERNAL_PROXY_COMMIT && \ 71 | go build \ 72 | -ldflags '-w -s' \ 73 | -a -installsuffix cgo -o /app/bin/external-proxy 74 | 75 | FROM build-app AS build-torrent-web-seeder 76 | 77 | ARG TORRENT_WEB_SEEDER_COMMIT 78 | 79 | ENV CGO_LDFLAGS="-static" GOOS=linux 80 | 81 | RUN echo $TORRENT_WEB_SEEDER_COMMIT > /app/bin/torrent-web-seeder.commit && \ 82 | git clone https://github.com/webtor-io/torrent-web-seeder /app/src/torrent-web-seeder && \ 83 | cd /app/src/torrent-web-seeder/server && \ 84 | git checkout $TORRENT_WEB_SEEDER_COMMIT && \ 85 | go build \ 86 | -ldflags '-w -s' \ 87 | -a -installsuffix cgo -o /app/bin/torrent-web-seeder 88 | 89 | FROM build-app AS build-torrent-web-seeder-cleaner 90 | 91 | ARG TORRENT_WEB_SEEDER_CLEANER_COMMIT 92 | 93 | ENV CGO_ENABLED=0 GOOS=linux 94 | 95 | RUN echo $TORRENT_WEB_SEEDER_CLEANER_COMMIT > /app/bin/torrent-web-seeder-cleaner.commit && \ 96 | git clone https://github.com/webtor-io/torrent-web-seeder-cleaner /app/src/torrent-web-seeder-cleaner && \ 97 | cd /app/src/torrent-web-seeder-cleaner && \ 98 | git checkout $TORRENT_WEB_SEEDER_CLEANER_COMMIT && \ 99 | go build \ 100 | -ldflags '-w -s' \ 101 | -a -installsuffix cgo -o /app/bin/torrent-web-seeder-cleaner 102 | 103 | FROM build-app AS build-content-transcoder 104 | 105 | ARG CONTENT_TRANSCODER_COMMIT 106 | 107 | ENV CGO_ENABLED=0 GOOS=linux 108 | 109 | RUN echo $CONTENT_TRANSCODER_COMMIT > /app/bin/content-transcoder.commit && \ 110 | git clone https://github.com/webtor-io/content-transcoder /app/src/content-transcoder && \ 111 | cd /app/src/content-transcoder && \ 112 | git checkout $CONTENT_TRANSCODER_COMMIT && \ 113 | go build \ 114 | -ldflags '-w -s' \ 115 | -a -installsuffix cgo -o /app/bin/content-transcoder 116 | 117 | FROM build-app AS build-torrent-archiver 118 | 119 | ARG TORRENT_ARCHIVER_COMMIT 120 | 121 | ENV CGO_ENABLED=0 GOOS=linux 122 | 123 | RUN echo $TORRENT_ARCHIVER_COMMIT > /app/bin/torrent-archiver.commit && \ 124 | git clone https://github.com/webtor-io/torrent-archiver /app/src/torrent-archiver && \ 125 | cd /app/src/torrent-archiver && \ 126 | git checkout $TORRENT_ARCHIVER_COMMIT && \ 127 | go build \ 128 | -ldflags '-w -s' \ 129 | -a -installsuffix cgo -o /app/bin/torrent-archiver 130 | 131 | FROM build-app AS build-srt2vtt 132 | 133 | ARG SRT2VTT_COMMIT 134 | 135 | ENV GOOS=linux CGO_LDFLAGS="-static" CGO_ENABLED=1 136 | 137 | RUN echo $SRT2VTT_COMMIT > /app/bin/srt2vtt.commit && \ 138 | git clone https://github.com/webtor-io/srt2vtt /app/src/srt2vtt && \ 139 | cd /app/src/srt2vtt && \ 140 | git checkout $SRT2VTT_COMMIT && \ 141 | go build \ 142 | -ldflags '-w -s' \ 143 | -a -installsuffix cgo -o /app/bin/srt2vtt 144 | 145 | FROM build-app AS build-torrent-http-proxy 146 | 147 | ARG TORRENT_HTTP_PROXY_COMMIT 148 | 149 | ENV CGO_ENABLED=0 GOOS=linux 150 | 151 | RUN echo $TORRENT_HTTP_PROXY_COMMIT > /app/bin/torrent-http-proxy.commit && \ 152 | git clone https://github.com/webtor-io/torrent-http-proxy /app/src/torrent-http-proxy && \ 153 | cd /app/src/torrent-http-proxy && \ 154 | git checkout $TORRENT_HTTP_PROXY_COMMIT && \ 155 | go build \ 156 | -ldflags '-w -s' \ 157 | -a -installsuffix cgo -o /app/bin/torrent-http-proxy 158 | 159 | FROM build-app AS build-rest-api 160 | 161 | ARG REST_API_COMMIT 162 | 163 | ENV CGO_ENABLED=0 GOOS=linux 164 | 165 | RUN echo $REST_API_COMMIT > /app/bin/rest-api.commit && \ 166 | git clone https://github.com/webtor-io/rest-api /app/src/rest-api && \ 167 | cd /app/src/rest-api && \ 168 | git checkout $REST_API_COMMIT && \ 169 | go build \ 170 | -ldflags '-w -s' \ 171 | -a -installsuffix cgo -o /app/bin/rest-api 172 | 173 | FROM build-app AS build-web-ui 174 | 175 | ARG WEB_UI_COMMIT 176 | 177 | ENV CGO_ENABLED=0 GOOS=linux 178 | 179 | RUN echo $WEB_UI_COMMIT > /app/bin/web-ui.commit && \ 180 | git clone https://github.com/webtor-io/web-ui /app/src/web-ui && \ 181 | cd /app/src/web-ui && \ 182 | git checkout $WEB_UI_COMMIT && \ 183 | go build \ 184 | -ldflags '-w -s -X google.golang.org/protobuf/reflect/protoregistry.conflictPolicy=ignore' \ 185 | -a -installsuffix cgo -o /app/bin/web-ui 186 | 187 | FROM node:$NODE_VER AS build-web-ui-assets 188 | 189 | WORKDIR /app 190 | 191 | COPY --from=build-web-ui /app/src/web-ui . 192 | 193 | RUN npm install 194 | 195 | RUN npm run build 196 | 197 | FROM alpine:$ALPINE_VER AS build-nginx-vod 198 | 199 | ARG NGINX_VERSION 200 | ARG VOD_MODULE_COMMIT 201 | ARG SECURE_TOKEN_MODULE_COMMIT 202 | 203 | RUN apk add --no-cache curl build-base openssl openssl-dev zlib-dev linux-headers pcre-dev && \ 204 | mkdir nginx nginx-vod-module nginx-secure-token-module && \ 205 | curl -sL https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz | tar -C /nginx --strip 1 -xz && \ 206 | curl -sL https://github.com/kaltura/nginx-vod-module/archive/${VOD_MODULE_COMMIT}.tar.gz | tar -C /nginx-vod-module --strip 1 -xz && \ 207 | curl -sL https://github.com/kaltura/nginx-secure-token-module/archive/${SECURE_TOKEN_MODULE_COMMIT}.tar.gz | tar -C /nginx-secure-token-module --strip 1 -xz 208 | 209 | WORKDIR /nginx 210 | RUN ./configure --prefix=/usr/local/nginx \ 211 | --add-module=../nginx-vod-module \ 212 | --add-module=../nginx-secure-token-module \ 213 | --with-http_ssl_module \ 214 | --with-file-aio \ 215 | --with-threads \ 216 | --with-cc-opt="-O3" && \ 217 | make && make install && \ 218 | rm -rf /nginx /nginx-vod-module /nginx-secure-token-module && \ 219 | rm -rf /usr/local/nginx/html /usr/local/nginx/conf/*.default 220 | 221 | 222 | FROM alpine:$ALPINE_VER AS base 223 | 224 | ARG S6_OVERLAY_VER 225 | ARG S6_VERBOSITY 226 | ENV S6_VERBOSITY=$S6_VERBOSITY 227 | 228 | ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VER}/s6-overlay-noarch.tar.xz /tmp 229 | RUN tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz 230 | ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VER}/s6-overlay-x86_64.tar.xz /tmp 231 | RUN tar -C / -Jxpf /tmp/s6-overlay-x86_64.tar.xz 232 | RUN apk --no-cache add redis ffmpeg ca-certificates openssl pcre zlib envsubst uuidgen 233 | 234 | WORKDIR /app 235 | 236 | COPY --from=build-torrent-store /app/bin/* . 237 | COPY --from=build-magnet2torrent /app/bin/* . 238 | COPY --from=build-external-proxy /app/bin/* . 239 | COPY --from=build-torrent-web-seeder /app/bin/* . 240 | COPY --from=build-torrent-web-seeder-cleaner /app/bin/* . 241 | COPY --from=build-content-transcoder /app/bin/* . 242 | COPY --from=build-torrent-archiver /app/bin/* . 243 | COPY --from=build-srt2vtt /app/bin/* . 244 | COPY --from=build-torrent-http-proxy /app/bin/* . 245 | COPY --from=build-rest-api /app/bin/* . 246 | COPY --from=build-web-ui /app/bin/* . 247 | COPY --from=build-web-ui /app/src/web-ui/templates /app/templates 248 | COPY --from=build-web-ui /app/src/web-ui/pub /app/pub 249 | COPY --from=build-web-ui-assets /app/assets/dist /app/assets/dist 250 | COPY --from=build-nginx-vod /usr/local/nginx /usr/local/nginx 251 | 252 | COPY etc/webtor /etc/webtor 253 | COPY etc/nginx/conf /usr/local/nginx/conf 254 | COPY s6-overlay /etc/s6-overlay 255 | 256 | ENV DOMAIN=http://localhost:8080 257 | 258 | EXPOSE 8080 259 | # EXPOSE 8090 8091 8092 8093 8094 8095 8096 8097 8098 260 | 261 | ENTRYPOINT ["/init"] 262 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2025 webtor.io 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Webtor, self-hosted 2 | 3 | This is the self-hosted version of [webtor.io](https://webtor.io), implemented as an all-in-one Docker image. 4 | 5 | ## Features 6 | 7 | - **Direct Download Link (DDL):** Select any file inside a torrent and download it directly. 8 | - **Instant Video and Audio Streaming:** Choose a video or audio file inside a torrent and start streaming immediately without needing to download it first. 9 | **Supported Formats:** 10 | - **Video:** `avi`, `mkv`, `mp4`, `webm`, `m4v`, `ts`, `vob` 11 | - **Audio:** `mp3`, `wav`, `ogg`, `flac`, `m4a` 12 | - **Download Entire Torrent as a ZIP Archive:** Download your torrent as a ZIP archive on-the-fly while preserving the original directory structure, without requiring a torrent client. 13 | - **Developer friendly** - with the [SDK](https://github.com/webtor-io/embed-sdk-js) you can provide your users with the ability to watch torrent-videos online on your website. 14 | 15 | ## Quick Setup 16 | 17 | 1. [Install Docker](https://docs.docker.com/get-docker/). 18 | 2. Start your Webtor instance with the following command: 19 | ```bash 20 | docker run -d -p 8080:8080 -v data:/data --name webtor --restart=always ghcr.io/webtor-io/self-hosted:latest 21 | ``` 22 | 3. Access the UI at . 23 | 4. You're all set! 24 | 25 | ## Setting a Custom Domain 26 | 27 | If you plan to access your instance from a different host or domain, set the `DOMAIN` environment variable like this: 28 | 29 | ```bash 30 | docker run -e DOMAIN=https://example.com -d -p 8080:8080 -v data:/data --name webtor --restart=always ghcr.io/webtor-io/self-hosted:latest 31 | ``` 32 | 33 | ## Configuring the Autocleaner 34 | 35 | Webtor automatically cleans old data when there is insufficient space on the device. You can configure this behavior using the following variables: 36 | 37 | ```bash 38 | CLEANER_FREE=35% 39 | CLEANER_KEEP_FREE=25% 40 | ``` 41 | 42 | - `CLEANER_FREE` specifies how much space to clean when triggered. 43 | - `CLEANER_KEEP_FREE` sets the threshold at which cleaning starts. 44 | 45 | Both variables can be defined as percentages or as byte values (e.g., `10G` or `100M`). 46 | -------------------------------------------------------------------------------- /etc/nginx/conf/nginx.template.conf: -------------------------------------------------------------------------------- 1 | worker_processes auto; 2 | 3 | events { 4 | worker_connections 4096; 5 | } 6 | 7 | http { 8 | log_format main '$remote_addr $remote_user [$time_local] "$request" ' 9 | '$status "$http_referer" "$http_user_agent"'; 10 | 11 | access_log /dev/null; 12 | error_log stderr; 13 | 14 | proxy_buffering off; 15 | 16 | default_type application/octet-stream; 17 | include /usr/local/nginx/conf/mime.types; 18 | 19 | sendfile on; 20 | tcp_nopush on; 21 | tcp_nodelay on; 22 | 23 | proxy_connect_timeout 300; 24 | proxy_send_timeout 300; 25 | proxy_read_timeout 300; 26 | 27 | # open_file_cache max=1000 inactive=5m; 28 | # open_file_cache_valid 2m; 29 | # open_file_cache_min_uses 1; 30 | # open_file_cache_errors on; 31 | 32 | # gzip on; 33 | # gzip_types application/vnd.apple.mpegurl video/f4m application/dash+xml text/xml text/vtt; 34 | # gzip_proxied any; 35 | 36 | keepalive_timeout 60; 37 | # keepalive_requests 1000; 38 | 39 | upstream remote { 40 | server ${TORRENT_HTTP_PROXY_SERVICE_HOST}:${TORRENT_HTTP_PROXY_SERVICE_PORT}; 41 | } 42 | 43 | map $http_x_tokenize $token { 44 | "no" ""; 45 | default $args; 46 | } 47 | 48 | server { 49 | vod_mode remote; 50 | vod_upstream_location /remote; 51 | vod_metadata_cache metadata_cache 1024m; 52 | vod_response_cache response_cache 128m; 53 | vod_base_url ''; 54 | 55 | vod_last_modified_types *; 56 | # vod_segment_duration 9000; 57 | # vod_align_segments_to_key_frames on; 58 | vod_dash_fragment_file_name_prefix "s"; 59 | vod_hls_segment_file_name_prefix "s"; 60 | 61 | vod_manifest_segment_durations_mode accurate; 62 | 63 | secure_token_avoid_cookies on; 64 | secure_token_types application/vnd.apple.mpegurl application/dash+xml text/xml; 65 | secure_token $token; 66 | 67 | vod_upstream_extra_args $token; 68 | listen ${NGINX_VOD_SERVICE_PORT}; 69 | root /opt/static; 70 | 71 | location /health { 72 | access_log off; 73 | return 200 "healthy\n"; 74 | } 75 | 76 | location ~ /remote/[^/]+/(.*) { 77 | internal; 78 | proxy_pass http://remote$http_x_full_path$is_args$args; 79 | } 80 | 81 | location /hls/ { 82 | vod hls; 83 | 84 | vod_bootstrap_segment_durations 2000; 85 | vod_bootstrap_segment_durations 2000; 86 | vod_bootstrap_segment_durations 2000; 87 | vod_bootstrap_segment_durations 4000; 88 | vod_bootstrap_segment_durations 4000; 89 | vod_bootstrap_segment_durations 6000; 90 | 91 | add_header Access-Control-Allow-Headers '*'; 92 | add_header Access-Control-Allow-Origin '*'; 93 | add_header Access-Control-Allow-Methods 'GET, HEAD, OPTIONS'; 94 | } 95 | } 96 | upstream web_ui { 97 | server ${WEB_UI_SERVICE_HOST}:${WEB_UI_SERVICE_PORT}; 98 | } 99 | upstream rest_api { 100 | server ${REST_API_SERVICE_HOST}:${REST_API_SERVICE_PORT}; 101 | } 102 | server { 103 | listen ${WEB_PORT}; 104 | location / { 105 | proxy_pass http://web_ui/; 106 | proxy_set_header Host $host; 107 | proxy_set_header X-Real-IP $remote_addr; 108 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 109 | } 110 | location /rest-api/ { 111 | proxy_pass http://rest_api/; 112 | proxy_set_header Host $host; 113 | proxy_set_header X-Real-IP $remote_addr; 114 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 115 | } 116 | location /torrent-http-proxy/ { 117 | proxy_pass http://remote/; 118 | proxy_set_header Host $host; 119 | proxy_set_header X-Real-IP $remote_addr; 120 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 121 | } 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /etc/webtor/common.env: -------------------------------------------------------------------------------- 1 | USE_PPROF=false 2 | USE_PROBE=false 3 | USE_PROM=false 4 | DATA_DIR=/data 5 | TORRENT_STORE_SERVICE_PORT=50051 6 | TORRENT_STORE_SERVICE_HOST=127.0.0.1 7 | MAGNET2TORRENT_SERVICE_PORT=50052 8 | MAGNET2TORRENT_SERVICE_HOST=127.0.0.1 9 | EXTERNAL_PROXY_SERVICE_PORT=8090 10 | EXTERNAL_PROXY_SERVICE_HOST=127.0.0.1 11 | REDIS_MASTER_SERVICE_PORT=6379 12 | REDIS_MASTER_SERVICE_HOST=127.0.0.1 13 | TORRENT_WEB_SEEDER_SERVICE_PORT=8091 14 | TORRENT_WEB_SEEDER_SERVICE_HOST=127.0.0.1 15 | CONTENT_TRANSCODER_SERVICE_PORT=8092 16 | CONTENT_TRANSCODER_SERVICE_HOST=127.0.0.1 17 | TORRENT_ARCHIVER_SERVICE_PORT=8093 18 | TORRENT_ARCHIVER_SERVICE_HOST=127.0.0.1 19 | SRT2VTT_SERVICE_PORT=8094 20 | SRT2VTT_SERVICE_HOST=127.0.0.1 21 | TORRENT_HTTP_PROXY_SERVICE_PORT=8095 22 | TORRENT_HTTP_PROXY_SERVICE_HOST=127.0.0.1 23 | REST_API_SERVICE_PORT=8096 24 | REST_API_SERVICE_HOST=127.0.0.1 25 | WEB_UI_SERVICE_PORT=8097 26 | WEB_UI_SERVICE_HOST=127.0.0.1 27 | NGINX_VOD_SERVICE_PORT=8098 28 | NGINX_VOD_SERVICE_HOST=127.0.0.1 29 | WEB_PORT=8080 30 | -------------------------------------------------------------------------------- /etc/webtor/torrent-http-proxy/config.yaml: -------------------------------------------------------------------------------- 1 | default: 2 | name: torrent-web-seeder 3 | endpointsProvider: Environment 4 | vod: 5 | name: nginx-vod 6 | endpointsProvider: Environment 7 | arch: 8 | name: torrent-archiver 9 | endpointsProvider: Environment 10 | hls: 11 | name: content-transcoder 12 | endpointsProvider: Environment 13 | vtt: 14 | name: srt2vtt 15 | endpointsProvider: Environment 16 | ext: 17 | name: external-proxy 18 | endpointsProvider: Environment -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/content-transcoder/dependencies.d/base: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webtor-io/self-hosted/f4c93e8b16eee3fd9cf9ebb22279d302700410a0/s6-overlay/s6-rc.d/content-transcoder/dependencies.d/base -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/content-transcoder/run: -------------------------------------------------------------------------------- 1 | #!/command/with-contenv sh 2 | set -a 3 | source /etc/webtor/common.env 4 | WEB_PORT=$CONTENT_TRANSCODER_SERVICE_PORT 5 | HLS_AAC_CODEC=aac 6 | OUTPUT=$DATA_DIR 7 | set +a 8 | /app/content-transcoder 2>&1 | s6-log p"[content-transcoder]" 1 -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/content-transcoder/type: -------------------------------------------------------------------------------- 1 | longrun -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/external-proxy/dependencies.d/base: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webtor-io/self-hosted/f4c93e8b16eee3fd9cf9ebb22279d302700410a0/s6-overlay/s6-rc.d/external-proxy/dependencies.d/base -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/external-proxy/run: -------------------------------------------------------------------------------- 1 | #!/command/with-contenv sh 2 | set -a 3 | source /etc/webtor/common.env 4 | WEB_PORT=$EXTERNAL_PROXY_SERVICE_PORT 5 | set +a 6 | /app/external-proxy 2>&1 | s6-log p"[external-proxy]" 1 -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/external-proxy/type: -------------------------------------------------------------------------------- 1 | longrun -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/generate-api-key-and-secret/dependencies.d/base: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webtor-io/self-hosted/f4c93e8b16eee3fd9cf9ebb22279d302700410a0/s6-overlay/s6-rc.d/generate-api-key-and-secret/dependencies.d/base -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/generate-api-key-and-secret/type: -------------------------------------------------------------------------------- 1 | oneshot -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/generate-api-key-and-secret/up: -------------------------------------------------------------------------------- 1 | /etc/s6-overlay/scripts/generate-api-key-and-secret 2>&1 -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/magnet2torrent/dependencies.d/base: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webtor-io/self-hosted/f4c93e8b16eee3fd9cf9ebb22279d302700410a0/s6-overlay/s6-rc.d/magnet2torrent/dependencies.d/base -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/magnet2torrent/run: -------------------------------------------------------------------------------- 1 | #!/command/with-contenv sh 2 | set -a 3 | source /etc/webtor/common.env 4 | LISTEN_PORT=$MAGNET2TORRENT_SERVICE_PORT 5 | set +a 6 | /app/magnet2torrent 2>&1 | s6-log p"[magnet2torrent]" 1 -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/magnet2torrent/type: -------------------------------------------------------------------------------- 1 | longrun -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/nginx-vod/dependencies.d/base: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webtor-io/self-hosted/f4c93e8b16eee3fd9cf9ebb22279d302700410a0/s6-overlay/s6-rc.d/nginx-vod/dependencies.d/base -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/nginx-vod/run: -------------------------------------------------------------------------------- 1 | #!/command/with-contenv sh 2 | set -a 3 | source /etc/webtor/common.env 4 | set +a 5 | envsubst '$REST_API_SERVICE_HOST $REST_API_SERVICE_PORT $TORRENT_HTTP_PROXY_SERVICE_HOST $TORRENT_HTTP_PROXY_SERVICE_PORT $NGINX_VOD_SERVICE_PORT $WEB_PORT $WEB_UI_SERVICE_PORT $WEB_UI_SERVICE_HOST' < /usr/local/nginx/conf/nginx.template.conf > /usr/local/nginx/conf/nginx.conf 6 | /usr/local/nginx/sbin/nginx -g "daemon off;" 2>&1 | s6-log p"[nginx]" 1 -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/nginx-vod/type: -------------------------------------------------------------------------------- 1 | longrun -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/redis/dependencies.d/base: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webtor-io/self-hosted/f4c93e8b16eee3fd9cf9ebb22279d302700410a0/s6-overlay/s6-rc.d/redis/dependencies.d/base -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/redis/run: -------------------------------------------------------------------------------- 1 | #!/command/with-contenv sh 2 | set -a 3 | source /etc/webtor/common.env 4 | set +a 5 | redis-server --port $REDIS_MASTER_SERVICE_PORT 2>&1 | s6-log p"[redis]" 1 -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/redis/type: -------------------------------------------------------------------------------- 1 | longrun -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/rest-api/dependencies.d/base: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webtor-io/self-hosted/f4c93e8b16eee3fd9cf9ebb22279d302700410a0/s6-overlay/s6-rc.d/rest-api/dependencies.d/base -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/rest-api/run: -------------------------------------------------------------------------------- 1 | #!/command/with-contenv sh 2 | set -a 3 | source /etc/webtor/common.env 4 | EXPORT_USE_SUBDOMAINS=false 5 | EXPORT_PATH_PREFIX=/torrent-http-proxy/ 6 | EXPORT_DOMAIN=$DOMAIN 7 | WEB_PORT=$REST_API_SERVICE_PORT 8 | GIN_MODE=release 9 | set +a 10 | /app/rest-api serve 2>&1 | s6-log p"[rest-api]" 1 -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/rest-api/type: -------------------------------------------------------------------------------- 1 | longrun -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/srt2vtt/dependencies.d/base: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webtor-io/self-hosted/f4c93e8b16eee3fd9cf9ebb22279d302700410a0/s6-overlay/s6-rc.d/srt2vtt/dependencies.d/base -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/srt2vtt/run: -------------------------------------------------------------------------------- 1 | #!/command/with-contenv sh 2 | set -a 3 | source /etc/webtor/common.env 4 | WEB_PORT=$SRT2VTT_SERVICE_PORT 5 | set +a 6 | /app/srt2vtt 2>&1 | s6-log p"[srt2vtt]" 1 -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/srt2vtt/type: -------------------------------------------------------------------------------- 1 | longrun -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/torrent-archiver/dependencies.d/base: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webtor-io/self-hosted/f4c93e8b16eee3fd9cf9ebb22279d302700410a0/s6-overlay/s6-rc.d/torrent-archiver/dependencies.d/base -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/torrent-archiver/run: -------------------------------------------------------------------------------- 1 | #!/command/with-contenv sh 2 | set -a 3 | source /etc/webtor/common.env 4 | WEB_PORT=$TORRENT_ARCHIVER_SERVICE_PORT 5 | set +a 6 | /app/torrent-archiver 2>&1 | s6-log p"[torrent-archiver]" 1 -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/torrent-archiver/type: -------------------------------------------------------------------------------- 1 | longrun -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/torrent-http-proxy/dependencies.d/base: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webtor-io/self-hosted/f4c93e8b16eee3fd9cf9ebb22279d302700410a0/s6-overlay/s6-rc.d/torrent-http-proxy/dependencies.d/base -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/torrent-http-proxy/dependencies.d/generate-api-key-and-secret: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webtor-io/self-hosted/f4c93e8b16eee3fd9cf9ebb22279d302700410a0/s6-overlay/s6-rc.d/torrent-http-proxy/dependencies.d/generate-api-key-and-secret -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/torrent-http-proxy/run: -------------------------------------------------------------------------------- 1 | #!/command/with-contenv sh 2 | set -a 3 | source /etc/webtor/common.env 4 | source /etc/webtor/secrets/api.env 5 | WEB_PORT=$TORRENT_HTTP_PROXY_SERVICE_PORT 6 | CONFIG_PATH=/etc/webtor/torrent-http-proxy/config.yaml 7 | set +a 8 | /app/torrent-http-proxy 2>&1 | s6-log p"[torrent-http-proxy]" 1 -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/torrent-http-proxy/type: -------------------------------------------------------------------------------- 1 | longrun -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/torrent-store/dependencies.d/base: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webtor-io/self-hosted/f4c93e8b16eee3fd9cf9ebb22279d302700410a0/s6-overlay/s6-rc.d/torrent-store/dependencies.d/base -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/torrent-store/run: -------------------------------------------------------------------------------- 1 | #!/command/with-contenv sh 2 | set -a 3 | source /etc/webtor/common.env 4 | GRPC_PORT=$TORRENT_STORE_SERVICE_PORT 5 | set +a 6 | /app/torrent-store serve 2>&1 | s6-log p"[torrent-http-proxy]" 1 -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/torrent-store/type: -------------------------------------------------------------------------------- 1 | longrun -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/torrent-web-seeder-cleaner/dependencies.d/base: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webtor-io/self-hosted/f4c93e8b16eee3fd9cf9ebb22279d302700410a0/s6-overlay/s6-rc.d/torrent-web-seeder-cleaner/dependencies.d/base -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/torrent-web-seeder-cleaner/run: -------------------------------------------------------------------------------- 1 | #!/command/with-contenv sh 2 | set -a 3 | source /etc/webtor/common.env 4 | set +a 5 | /app/torrent-web-seeder-cleaner s 2>&1 | s6-log p"[torrent-web-seeder-cleaner]" 1 -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/torrent-web-seeder-cleaner/type: -------------------------------------------------------------------------------- 1 | longrun -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/torrent-web-seeder/dependencies.d/base: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webtor-io/self-hosted/f4c93e8b16eee3fd9cf9ebb22279d302700410a0/s6-overlay/s6-rc.d/torrent-web-seeder/dependencies.d/base -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/torrent-web-seeder/run: -------------------------------------------------------------------------------- 1 | #!/command/with-contenv sh 2 | set -a 3 | source /etc/webtor/common.env 4 | WEB_PORT=$TORRENT_WEB_SEEDER_SERVICE_PORT 5 | USE_STAT=false 6 | set +a 7 | /app/torrent-web-seeder 2>&1 | s6-log p"[torrent-web-seeder]" 1 -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/torrent-web-seeder/type: -------------------------------------------------------------------------------- 1 | longrun -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/user/contents.d/content-transcoder: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webtor-io/self-hosted/f4c93e8b16eee3fd9cf9ebb22279d302700410a0/s6-overlay/s6-rc.d/user/contents.d/content-transcoder -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/user/contents.d/external-proxy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webtor-io/self-hosted/f4c93e8b16eee3fd9cf9ebb22279d302700410a0/s6-overlay/s6-rc.d/user/contents.d/external-proxy -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/user/contents.d/generate-api-key-and-secret: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webtor-io/self-hosted/f4c93e8b16eee3fd9cf9ebb22279d302700410a0/s6-overlay/s6-rc.d/user/contents.d/generate-api-key-and-secret -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/user/contents.d/magnet2torrent: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webtor-io/self-hosted/f4c93e8b16eee3fd9cf9ebb22279d302700410a0/s6-overlay/s6-rc.d/user/contents.d/magnet2torrent -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/user/contents.d/nginx-vod: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webtor-io/self-hosted/f4c93e8b16eee3fd9cf9ebb22279d302700410a0/s6-overlay/s6-rc.d/user/contents.d/nginx-vod -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/user/contents.d/redis: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webtor-io/self-hosted/f4c93e8b16eee3fd9cf9ebb22279d302700410a0/s6-overlay/s6-rc.d/user/contents.d/redis -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/user/contents.d/rest-api: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webtor-io/self-hosted/f4c93e8b16eee3fd9cf9ebb22279d302700410a0/s6-overlay/s6-rc.d/user/contents.d/rest-api -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/user/contents.d/srt2vtt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webtor-io/self-hosted/f4c93e8b16eee3fd9cf9ebb22279d302700410a0/s6-overlay/s6-rc.d/user/contents.d/srt2vtt -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/user/contents.d/torrent-archiver: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webtor-io/self-hosted/f4c93e8b16eee3fd9cf9ebb22279d302700410a0/s6-overlay/s6-rc.d/user/contents.d/torrent-archiver -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/user/contents.d/torrent-http-proxy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webtor-io/self-hosted/f4c93e8b16eee3fd9cf9ebb22279d302700410a0/s6-overlay/s6-rc.d/user/contents.d/torrent-http-proxy -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/user/contents.d/torrent-store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webtor-io/self-hosted/f4c93e8b16eee3fd9cf9ebb22279d302700410a0/s6-overlay/s6-rc.d/user/contents.d/torrent-store -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/user/contents.d/torrent-web-seeder: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webtor-io/self-hosted/f4c93e8b16eee3fd9cf9ebb22279d302700410a0/s6-overlay/s6-rc.d/user/contents.d/torrent-web-seeder -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/user/contents.d/torrent-web-seeder-cleaner: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webtor-io/self-hosted/f4c93e8b16eee3fd9cf9ebb22279d302700410a0/s6-overlay/s6-rc.d/user/contents.d/torrent-web-seeder-cleaner -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/user/contents.d/web-ui: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webtor-io/self-hosted/f4c93e8b16eee3fd9cf9ebb22279d302700410a0/s6-overlay/s6-rc.d/user/contents.d/web-ui -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/web-ui/dependencies.d/base: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webtor-io/self-hosted/f4c93e8b16eee3fd9cf9ebb22279d302700410a0/s6-overlay/s6-rc.d/web-ui/dependencies.d/base -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/web-ui/dependencies.d/generate-api-key-and-secret: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/webtor-io/self-hosted/f4c93e8b16eee3fd9cf9ebb22279d302700410a0/s6-overlay/s6-rc.d/web-ui/dependencies.d/generate-api-key-and-secret -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/web-ui/run: -------------------------------------------------------------------------------- 1 | #!/command/with-contenv sh 2 | set -a 3 | source /etc/webtor/common.env 4 | source /etc/webtor/secrets/api.env 5 | WEBTOR_API_KEY=$API_KEY 6 | WEBTOR_API_SECRET=$API_SECRET 7 | WEB_PORT=$WEB_UI_SERVICE_PORT 8 | GIN_MODE=release 9 | set +a 10 | cd /app && ./web-ui serve 2>&1 | s6-log p"[web-ui]" 1 -------------------------------------------------------------------------------- /s6-overlay/s6-rc.d/web-ui/type: -------------------------------------------------------------------------------- 1 | longrun -------------------------------------------------------------------------------- /s6-overlay/scripts/generate-api-key-and-secret: -------------------------------------------------------------------------------- 1 | #!/command/with-contenv sh 2 | 3 | log() { 4 | echo "$1" | s6-log p"[generate-api-key-and-secret]" 1 5 | } 6 | 7 | f=/etc/webtor/secrets/api.env 8 | mkdir -p "$(dirname "$f")" 9 | if [ -n "$API_KEY" ] && [ -n "$API_SECRET" ]; then 10 | log "using provided API_KEY and API_SECRET" 11 | key=$API_KEY 12 | secret=$API_SECRET 13 | elif [ -f $f ]; then 14 | log "key file ${f} already exists" 15 | exit 16 | else 17 | log "generating API_KEY and API_SECRET" 18 | key=$(uuidgen | tr '[:upper:]' '[:lower:]') 19 | secret=$(uuidgen | sha1sum | head -c 40) 20 | fi 21 | log "storing API_KEY and API_SECRET to ${f}" 22 | echo "API_KEY=${key}" > $f 23 | echo "API_SECRET=${secret}" >> $f 24 | --------------------------------------------------------------------------------