diff --git a/Dockerfile b/Dockerfile
index 1fa3a31..719f1bb 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -4,7 +4,7 @@ FROM nginx:alpine
# Copy our custom Nginx configuration and script
COPY nginx.conf /etc/nginx/nginx.conf.template
COPY docker-entrypoint.sh /docker-entrypoint.sh
-
+COPY matomo.js /matomo.js.template
# Make the script executable
RUN chmod +x /docker-entrypoint.sh
diff --git a/docker-compose.yml b/docker-compose.yml
index 254450f..96fd975 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -5,7 +5,7 @@ services:
build:
context: .
dockerfile: Dockerfile
- image: codeberg.org/iridium-net/lan-to-nginx:latest
+ image: codeberg.org/iridium-net/lan-to-nginx:truenas
environment:
- BACKEND_ADDRESS=192.168.8.1 # Replace with your backend address
- BACKEND_PORT=80 # Replace with your backend port
diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh
index ccd7bf7..8d8989c 100644
--- a/docker-entrypoint.sh
+++ b/docker-entrypoint.sh
@@ -3,10 +3,16 @@
PROTOCOL="${PROTOCOL:-http}"
# Replace placeholders with environment variable values
-envsubst '$BACKEND_ADDRESS $BACKEND_PORT $PROTOCOL' < /etc/nginx/nginx.conf.template > /etc/nginx/nginx.conf
-
-# Use envsubst to replace environment variables in nginx.conf.template and output to nginx.conf
-#envsubst '$BACKEND_ADDRESS,$BACKEND_PORT' < /etc/nginx/nginx.conf.template > /etc/nginx/nginx.conf
+envsubst '$BACKEND_ADDRESS $BACKEND_PORT $PROTOCOL $MATOMO_URL $MATOMO_SITE_ID' < /etc/nginx/nginx.conf.template > /etc/nginx/nginx.conf
+# Substitute environment variables in matomo.js
+envsubst '$MATOMO_URL $MATOMO_SITE_ID' < /matomo.js.template > /matomo.js
# Start nginx in the foreground
+curl -k -I $PROTOCOL://$BACKEND_ADDRESS:$BACKEND_PORT
+echo checking nginx modules
+nginx -V 2>&1 | grep -o http_sub_module
+echo /matomo.js
+cat /matomo.js
+echo /etc/nginx/nginx.conf
+cat /etc/nginx/nginx.conf
exec nginx -g 'daemon off;'
diff --git a/nginx.conf b/nginx.conf
index 7dac1c4..9af542a 100644
--- a/nginx.conf
+++ b/nginx.conf
@@ -6,22 +6,43 @@ events {
}
http {
- include /etc/nginx/mime.types;
default_type application/octet-stream;
server {
listen 80;
+ # Define MIME type
+ types {
+ text/html html htm shtml;
+ }
+
location / {
- # Use the placeholders for the proxy pass (these will be replaced by envsubst)
- proxy_pass ${PROTOCOL}://$BACKEND_ADDRESS:$BACKEND_PORT;
-# proxy_pass http://$BACKEND_ADDRESS:$BACKEND_PORT;
+ # Use the placeholders for the proxy pass
+ proxy_pass ${PROTOCOL}://${BACKEND_ADDRESS}:${BACKEND_PORT};
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_set_header Accept-Encoding "";
+ proxy_buffering off;
+ proxy_ssl_verify off; # Skip SSL verification, be cautious
+
+ # Enable response body filtering
+ sub_filter_once off;
+
+ # Inject the Matomo content just before
+# sub_filter '' '';
+ sub_filter '' '';
+ sub_filter_types application/xml application/json text/css text/javascript application/javascript text/plain;
+
}
+
+# location /matomo.js {
+# alias /matomo.js;
+# types { application/javascript js; } # Explicitly set the MIME type for .js files
+# default_type application/javascript; # Setting default MIME type for this location block
+# }
}
}
diff --git a/truenas.yml b/truenas.yml
new file mode 100644
index 0000000..291bcbf
--- /dev/null
+++ b/truenas.yml
@@ -0,0 +1,33 @@
+version: "3.9"
+
+networks:
+ traefik:
+ external: true
+
+services:
+ truenas:
+ image: codeberg.org/iridium-net/lan-to-nginx:truenas
+ environment:
+ - BACKEND_ADDRESS=192.168.8.47
+ - BACKEND_PORT=443
+ - PROTOCOL=https
+ - MATOMO_URL=//m.nixc.us/ # Replace with your actual Matomo URL if different.
+ - MATOMO_SITE_ID=1 # Replace with your actual Site ID if different.
+ networks:
+ - traefik
+ deploy:
+ replicas: 1
+ placement:
+ constraints:
+ - node.hostname == macmini7
+ labels:
+ - "us.nixc.autodeploy=true"
+ - "traefik.enable=true"
+ - "traefik.http.routers.truenas-proxy.tls=true"
+ - "traefik.http.services.truenas-proxy.loadbalancer.server.port=80"
+ - "traefik.http.routers.truenas-proxy.rule=Host(`truenas.nixc.us`)"
+ - "traefik.http.routers.truenas-proxy.entrypoints=websecure"
+ - "traefik.http.routers.truenas-proxy.tls.certresolver=letsencryptresolver"
+ - "traefik.http.routers.truenas-proxy.service=truenas-proxy"
+ - "traefik.docker.network=traefik"
+# - 'traefik.http.routers.truenas-proxy.middlewares=authelia_authelia@docker'
diff --git a/unifi.yml b/unifi.yml
deleted file mode 100644
index c53bd1c..0000000
--- a/unifi.yml
+++ /dev/null
@@ -1,30 +0,0 @@
-version: "3.9"
-
-networks:
- traefik:
- external: true
-
-services:
- unifi:
- image: codeberg.org/iridium-net/lan-to-nginx:latest
- environment:
- - BACKEND_ADDRESS=192.168.8.1
- - BACKEND_PORT=443
- - PROTOCOL=https
- networks:
- - traefik
- deploy:
- replicas: 1
- placement:
- constraints:
- - node.hostname == macmini7
- labels:
- - "us.nixc.autodeploy=true"
- - "traefik.enable=true"
- - "traefik.http.routers.nginx-proxy.tls=true"
- - "traefik.http.services.nginx-proxy.loadbalancer.server.port=80"
- - "traefik.http.routers.nginx-proxy.rule=Host(`unifi.nixc.us`)"
- - "traefik.http.routers.nginx-proxy.entrypoints=websecure"
- - "traefik.http.routers.nginx-proxy.tls.certresolver=letsencryptresolver"
- - "traefik.http.routers.nginx-proxy.service=nginx-proxy"
- - "traefik.docker.network=traefik"