init
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Simon Bruder 2019-05-27 14:25:44 +00:00
commit 585b470624
No known key found for this signature in database
GPG key ID: 6F03E0000CC5B62F
5 changed files with 84 additions and 0 deletions

13
.drone.yml Normal file
View file

@ -0,0 +1,13 @@
kind: pipeline
name: default
steps:
- name: docker
image: plugins/docker
settings:
registry: r.sbruder.de
username:
from_secret: docker_username
password:
from_secret: docker_password
repo: r.sbruder.de/tor-reverseproxy

12
Dockerfile Normal file
View file

@ -0,0 +1,12 @@
FROM alpine
RUN apk add --no-cache \
nginx \
su-exec \
tor
COPY torrc /etc/tor/torrc
COPY nginx.conf /etc/nginx/nginx.conf
COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

14
entrypoint.sh Executable file
View file

@ -0,0 +1,14 @@
#!/bin/sh
su-exec tor tor -f /etc/tor/torrc
tor_domain=$(cat /var/lib/tor/hidden-service/hostname)
main_domain=$(echo $MAIN_DOMAIN|sed 's/\./\\\./')
sed -i \
-e "s/@@TOR_DOMAIN@@/$tor_domain/g" \
-e "s/@@MAIN_DOMAIN@@/$main_domain/g" \
/etc/nginx/nginx.conf
echo $tor_domain
nginx -g 'daemon off;'

39
nginx.conf Normal file
View file

@ -0,0 +1,39 @@
user nginx;
worker_processes 1;
error_log /dev/stderr warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
access_log none;
keepalive_timeout 65;
resolver 46.182.19.48 ipv6=off;
server_names_hash_bucket_size 128;
server_tokens off;
server {
listen 80;
listen [::]:80;
server_name ~^(?<subdomain>.+)\.@@TOR_DOMAIN@@$;
location / {
proxy_pass https://$subdomain.@@MAIN_DOMAIN@@$uri;
}
}
server {
listen 80;
listen [::]:80;
server_name @@TOR_DOMAIN@@;
location / {
proxy_pass https://@@MAIN_DOMAIN@@$uri;
}
}
}

6
torrc Normal file
View file

@ -0,0 +1,6 @@
RunAsDaemon 1
DataDirectory /var/lib/tor
HiddenServiceDir /var/lib/tor/hidden-service/
HiddenServiceVersion 3
HiddenServicePort 80 127.0.0.1:80