using i2pshark newest version
This commit is contained in:
parent
e58555e5e6
commit
5dd7bcc3de
36
files/i2psnark/Dockerfile
Normal file
36
files/i2psnark/Dockerfile
Normal file
@ -0,0 +1,36 @@
|
||||
FROM alpine:latest
|
||||
|
||||
WORKDIR /
|
||||
|
||||
ARG HOST_IP=0.0.0.0
|
||||
ARG HOST_GID=1000
|
||||
ARG HOST_UID=1000
|
||||
|
||||
# Install dependencies
|
||||
RUN apk add --no-cache \
|
||||
wget \
|
||||
unzip \
|
||||
openjdk8-jre-base \
|
||||
su-exec \
|
||||
shadow
|
||||
|
||||
# Create user and group
|
||||
RUN addgroup -g ${HOST_GID} i2psnark \
|
||||
&& adduser -h /i2psnark -G i2psnark -u ${HOST_UID} -D i2psnark
|
||||
|
||||
# Download and install i2psnark
|
||||
RUN wget -O /tmp/i2psnark-standalone.zip \
|
||||
"https://i2pplus.github.io/installers/i2psnark-standalone.zip" \
|
||||
&& unzip /tmp/i2psnark-standalone.zip -d /tmp \
|
||||
&& mkdir -p /snark \
|
||||
&& mv /tmp/standalone /snark/i2psnark \
|
||||
&& rm -f /tmp/i2psnark-standalone.zip \
|
||||
&& chown -R i2psnark:i2psnark /snark \
|
||||
&& sed -i "s|127.0.0.1|${HOST_IP}|g" /snark/i2psnark/jetty-i2psnark.xml
|
||||
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
|
||||
EXPOSE 8002
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
12
files/i2psnark/entrypoint.sh
Normal file
12
files/i2psnark/entrypoint.sh
Normal file
@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
set -euo pipefail
|
||||
|
||||
HOST_GID=`getent group i2psnark | cut -d: -f3`
|
||||
|
||||
# Ensure user rights
|
||||
chown -R i2psnark:$HOST_GID /i2psnark
|
||||
chown i2psnark:$HOST_GID /snark/downloads
|
||||
|
||||
|
||||
cd /snark/i2psnark
|
||||
exec ./launch-i2psnark
|
||||
@ -23,12 +23,17 @@
|
||||
content: "{{ localservices.wg_client.wg_conf }}"
|
||||
dest: "{{ path }}/config/wg0.conf"
|
||||
|
||||
- name: template i2psnark.conf
|
||||
- name: populate i2psnark templates
|
||||
template:
|
||||
src: "i2psnark.conf.j2"
|
||||
dest: "{{ path }}/config/i2psnark.config"
|
||||
src: "i2psnark/{{ item.path }}"
|
||||
dest: "{{ path }}/config/{{ item.path | regex_replace('\\.j2$', '') }}"
|
||||
with_filetree: "{{ role_path }}/templates/i2psnark"
|
||||
when: localservices.i2psnark.url | length > 0
|
||||
|
||||
- name: copy docker files for i2psnark
|
||||
copy:
|
||||
src: i2psnark
|
||||
dest: "{{ path }}"
|
||||
|
||||
- name: template docker compose
|
||||
template:
|
||||
|
||||
@ -77,34 +77,39 @@ services:
|
||||
{% if localservices.i2psnark.url | length > 0 %}
|
||||
|
||||
i2psnark:
|
||||
image: ypopovych/i2psnark:latest
|
||||
build:
|
||||
dockerfile: Dockerfile
|
||||
context: i2psnark
|
||||
volumes:
|
||||
- ./config/i2psnark.config:/snark/config/i2psnark.config
|
||||
- ./config/i2psnark.config:/snark/i2psnark/i2psnark.config
|
||||
- {{ localservices.i2psnark.data_path }}:/snark/downloads
|
||||
networks:
|
||||
- proxy
|
||||
environment:
|
||||
HOSTNAMES: "{{ localservices.i2psnark.url }}"
|
||||
I2CP_HOST: "{{ localservices.i2psnark.i2pc_host }}"
|
||||
restart: "on-failure"
|
||||
|
||||
i2psnark-proxy:
|
||||
image: nginx:alpine
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
- i2psnark
|
||||
volumes:
|
||||
- ./config/i2psnark_nginx.conf:/etc/nginx/templates/default.conf.template:ro
|
||||
networks:
|
||||
- proxy
|
||||
labels:
|
||||
traefik.enable: true
|
||||
|
||||
traefik.http.routers.i2psnark.rule: "Host(`{{ localservices.i2psnark.url }}`) && (PathPrefix(`/i2psnark/`) || Path(`/`))"
|
||||
traefik.http.routers.i2psnark.tls: "true"
|
||||
traefik.http.routers.i2psnark.tls.certresolver: hetzner
|
||||
|
||||
traefik.http.routers.i2psnark.service: i2psnark
|
||||
traefik.http.services.i2psnark.loadbalancer.server.port: "8002"
|
||||
traefik.http.services.i2psnark.loadbalancer.server.port: "8080"
|
||||
|
||||
traefik.http.middlewares.i2psnark-redirect.redirectregex.regex: "^/$"
|
||||
traefik.http.middlewares.i2psnark-redirect.redirectregex.replacement: "/i2psnark/"
|
||||
traefik.http.middlewares.i2psnark-redirect.redirectregex.permanent: "true"
|
||||
traefik.http.routers.i2psnark.middlewares: local-only@file, traefik-auth@file
|
||||
|
||||
{% endif %}
|
||||
|
||||
traefik.http.middlewares.i2psnark-headers.headers.customRequestHeaders.Host: {{ localservices.i2psnark.url }}
|
||||
traefik.http.middlewares.i2psnark-headers.headers.customRequestHeaders.X-Forwarded-Proto: https
|
||||
traefik.http.routers.i2psnark.middlewares: local-only@file, traefik-auth@file, i2psnark-redirect, i2psnark-headers
|
||||
{% endif %}
|
||||
|
||||
networks:
|
||||
proxy:
|
||||
|
||||
40
templates/i2psnark/i2psnark_nginx.conf.j2
Normal file
40
templates/i2psnark/i2psnark_nginx.conf.j2
Normal file
@ -0,0 +1,40 @@
|
||||
# We need to use this as a proxy because allowing non local domains
|
||||
# doese not work for i2pshark standalone...
|
||||
|
||||
server {
|
||||
listen 8080;
|
||||
server_name _;
|
||||
|
||||
# Redirect the root to the I2PSnark application.
|
||||
location = / {
|
||||
return 302 https://{{ localservices.i2psnark.url }}/i2psnark/;
|
||||
}
|
||||
|
||||
location / {
|
||||
proxy_pass http://i2psnark:8002;
|
||||
proxy_http_version 1.1;
|
||||
|
||||
# I2PSnark requires localhost headers.
|
||||
proxy_set_header Host 127.0.0.1;
|
||||
proxy_set_header Origin http://127.0.0.1;
|
||||
|
||||
# Preserve HTTPS information.
|
||||
proxy_set_header X-Forwarded-Proto https;
|
||||
proxy_set_header X-Forwarded-Host {{ localservices.i2psnark.url }};
|
||||
|
||||
# Rewrite absolute redirects from the backend.
|
||||
proxy_redirect http://127.0.0.1:8002/ https://{{ localservices.i2psnark.url }}/;
|
||||
proxy_redirect http://127.0.0.1/ https://{{ localservices.i2psnark.url }}/;
|
||||
|
||||
# Forward client information.
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
|
||||
# Support longer-running requests.
|
||||
proxy_connect_timeout 60s;
|
||||
proxy_send_timeout 300s;
|
||||
proxy_read_timeout 300s;
|
||||
|
||||
proxy_buffering off;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user