diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..842a3c7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.temp +tor/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..64dfb1d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM nginx:1.20-alpine + +# Metadata about the docker image +LABEL name="tor-nginx-proxy" +LABEL version="1.0.0-beta-1.0" +LABEL maintainer="Harshit Budhraja (https://github.com/harshit-budhraja)" + +# Update packages and install tor +RUN apk --update --allow-untrusted --repository http://dl-4.alpinelinux.org/alpine/edge/community/ add \ + tor && rm -rf /var/cache/apk/* /tmp/* /var/tmp/* + +# Copy nginx and tor configurations +COPY default.conf.template /etc/nginx/templates/default.conf.template +COPY torrc /etc/tor/torrc + +# Add script to start tor +COPY start-tor.sh /docker-entrypoint.d/40-start-tor.sh +RUN chmod +x /docker-entrypoint.d/40-start-tor.sh \ No newline at end of file diff --git a/default.conf.template b/default.conf.template new file mode 100644 index 0000000..36a4682 --- /dev/null +++ b/default.conf.template @@ -0,0 +1,12 @@ +server { + listen ${NGINX_PORT}; + + location / { + proxy_pass ${NGINX_PROXY_URL}; + proxy_set_header Host $host:$server_port; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection upgrade; + proxy_set_header Accept-Encoding gzip; + } +} \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..35c53db --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,15 @@ +--- +version: '3' + +services: + tor-nginx-proxy: + container_name: tor-nginx-proxy + image: harshitbudhraja/tor-nginx-proxy:latest + restart: unless-stopped + environment: + - NGINX_PORT=80 + - NGINX_PROXY_URL= + ports: + - 3000:80 + volumes: + - ./tor:/var/lib/tor/ \ No newline at end of file diff --git a/start-tor.sh b/start-tor.sh new file mode 100644 index 0000000..0468e11 --- /dev/null +++ b/start-tor.sh @@ -0,0 +1,2 @@ +#!/bin/sh +tor -f /etc/tor/torrc \ No newline at end of file diff --git a/torrc b/torrc new file mode 100644 index 0000000..b437f78 --- /dev/null +++ b/torrc @@ -0,0 +1,4 @@ +HiddenServiceDir /var/lib/tor/hidden_service/ +HiddenServicePort 80 127.0.0.1:80 +Log notice stdout +RunAsDaemon 1