docker is working onion site reachable from host
This commit is contained in:
parent
46c925b0c5
commit
fac528684f
38
Dockerfile
38
Dockerfile
@ -2,16 +2,40 @@ FROM alpine:3.20
|
||||
|
||||
RUN apk update && \
|
||||
apk upgrade && \
|
||||
apk add --no-cache nginx, openssh, tor \
|
||||
&& rm -rf /var/cache/apk/*
|
||||
apk add --no-cache nginx tor openssh && \
|
||||
rm -rf /var/cache/apk/*
|
||||
|
||||
# Setup SSH
|
||||
|
||||
RUN mkdir -p /var/run/sshd && \
|
||||
ssh-keygen -A && \
|
||||
echo "root:password" | chpasswd
|
||||
|
||||
COPY sshd_config /etc/ssh/sshd_config
|
||||
|
||||
# Setup Nginx
|
||||
RUN mkdir -p /var/www/html && \
|
||||
mkdir -p /var/log/nginx && \
|
||||
mkdir -p /run/nginx && \
|
||||
chown -R nginx:nginx /var/www/html && \
|
||||
chown -R nginx:nginx /var/log/nginx && \
|
||||
chown -R nginx:nginx /run/nginx
|
||||
|
||||
COPY nginx.conf /etc/nginx/nginx.conf
|
||||
COPY torrc /etc/tor/torrc
|
||||
COPY sshd_config /etc/ssh/sshd_config
|
||||
COPY index.html /var/www/html/index.html
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
|
||||
# Setup Tor
|
||||
RUN mkdir -p /var/lib/tor && \
|
||||
mkdir -p /var/log/tor
|
||||
|
||||
COPY torrc /etc/tor/torrc
|
||||
|
||||
# Copy the index.html and entrypoint script
|
||||
COPY index.html /var/www/html/index.html
|
||||
|
||||
# Copy the entrypoint script and make it executable
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
|
||||
EXPOSE 4242
|
||||
|
||||
CMD ["sh", "-c", "nginx && tor -f /etc/tor/torrc"]
|
||||
CMD ["/entrypoint.sh"]
|
||||
|
||||
22
nginx.conf
22
nginx.conf
@ -1,10 +1,20 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
http
|
||||
{
|
||||
include mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
location / {
|
||||
server {
|
||||
listen 80;
|
||||
root /var/www/html;
|
||||
index index.html index.htm;
|
||||
try_files $uri $uri/ =404;
|
||||
index index.html;
|
||||
server_name localhost;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ =404;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -3,8 +3,5 @@
|
||||
Port 4242
|
||||
PermitRootLogin yes
|
||||
PasswordAuthentication yes
|
||||
ChallengeResponseAuthentication no
|
||||
UsePAM yes
|
||||
X11Forwarding no
|
||||
AllowTcpForwarding no
|
||||
PermitEmptyPasswords no
|
||||
|
||||
|
||||
20
start.sh
Normal file → Executable file
20
start.sh
Normal file → Executable file
@ -3,8 +3,26 @@
|
||||
IMAGE_NAME="ft_onion_image"
|
||||
CONTAINER_NAME="ft_onion_container"
|
||||
|
||||
#remove any existing container with the same name
|
||||
if [ "$(docker ps -aq -f name=$CONTAINER_NAME)" ]; then
|
||||
docker rm -f $CONTAINER_NAME
|
||||
fi
|
||||
|
||||
# Build the Docker image
|
||||
docker build -t $IMAGE_NAME -f Dockerfile .
|
||||
|
||||
# Run the Docker container
|
||||
docker run --name $CONTAINER_NAME -d $IMAGE_NAME -p 4242:4242 --restart unless-stopped
|
||||
docker run --name $CONTAINER_NAME -d -p 4242:4242 --restart unless-stopped $IMAGE_NAME
|
||||
|
||||
# Wait for the container to start
|
||||
echo "Waiting for the container to start..."
|
||||
sleep 5
|
||||
# Check if the container is running
|
||||
if [ "$(docker ps -q -f name=$CONTAINER_NAME)" ]; then
|
||||
echo "Container $CONTAINER_NAME is running."
|
||||
docker exec $CONTAINER_NAME cat /var/lib/tor/hidden_service/hostname
|
||||
else
|
||||
echo "Failed to start container $CONTAINER_NAME."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user