Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IPv6 support #109

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ ENV GENERICCACHE_VERSION=2 \
CACHE_DISK_SIZE=1000000m \
CACHE_MAX_AGE=3560d \
CACHE_SLICE_SIZE=1m \
ENABLE_IPV6=false \
UPSTREAM_DNS="8.8.8.8 8.8.4.4" \
BEAT_TIME=1h \
LOGFILE_RETENTION=3560 \
Expand Down
1 change: 1 addition & 0 deletions overlay/etc/nginx/sites-available/10_generic.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

server {
listen 80 reuseport;
ENABLE_IPV6;

access_log /data/logs/access.log cachelog;
error_log /data/logs/error.log;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resolver UPSTREAM_DNS ipv6=off;
resolver UPSTREAM_DNS;

location / {

Expand Down
14 changes: 10 additions & 4 deletions overlay/hooks/entrypoint-pre.d/10_setup.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
#!/bin/sh
#!/bin/bash
set -e

# Preprocess UPSTREAM_DNS to allow for multiple resolvers using the same syntax as lancache-dns
UPSTREAM_DNS="$(echo -n "${UPSTREAM_DNS}" | sed 's/[;]/ /g')"

echo "worker_processes ${NGINX_WORKER_PROCESSES};" > /etc/nginx/workers.conf
sed -i "s/^user .*/user ${WEBUSER};/" /etc/nginx/nginx.conf
sed -i "s/CACHE_MEM_SIZE/${CACHE_MEM_SIZE}/" /etc/nginx/conf.d/20_proxy_cache_path.conf
sed -i "s/CACHE_MEM_SIZE/${CACHE_MEM_SIZE}/" /etc/nginx/conf.d/20_proxy_cache_path.conf
sed -i "s/CACHE_DISK_SIZE/${CACHE_DISK_SIZE}/" /etc/nginx/conf.d/20_proxy_cache_path.conf
sed -i "s/CACHE_MAX_AGE/${CACHE_MAX_AGE}/" /etc/nginx/sites-available/generic.conf.d/root/20_cache.conf
sed -i "s/CACHE_MAX_AGE/${CACHE_MAX_AGE}/" /etc/nginx/sites-available/generic.conf.d/root/20_cache.conf
sed -i "s/slice 1m;/slice ${CACHE_SLICE_SIZE};/" /etc/nginx/sites-available/generic.conf.d/root/20_cache.conf
sed -i "s/UPSTREAM_DNS/${UPSTREAM_DNS}/" /etc/nginx/sites-available/generic.conf.d/10_generic.conf
if [[ ${ENABLE_IPV6} != "true" ]]; then
sed -i "s/UPSTREAM_DNS/${UPSTREAM_DNS} ipv6=off/" /etc/nginx/sites-available/generic.conf.d/10_generic.conf
sed -i "/ENABLE_IPV6/d" /etc/nginx/sites-available/10_generic.conf
else
sed -i "s/UPSTREAM_DNS/${UPSTREAM_DNS}/" /etc/nginx/sites-available/generic.conf.d/10_generic.conf
sed -i "s/ENABLE_IPV6/listen [::]:80 reuseport/" /etc/nginx/sites-available/10_generic.conf
fi