Просмотр исходного кода

feat: update captive portal deployment guide for containerized Squid setup

Manuel 2 месяцев назад
Родитель
Сommit
b7dd5ce893
2 измененных файлов с 51 добавлено и 1 удалено
  1. 25 0
      docs/captive_portal/README.md
  2. 26 1
      docs/captive_portal/README_es.md

+ 25 - 0
docs/captive_portal/README.md

@@ -240,6 +240,31 @@ For a helper on a separate Squid host:
 
 The helper must not print log messages to stdout. Squid uses stdout for the ACL protocol. Application diagnostics belong on stderr or in the application log.
 
+### Squid in a container and SquidStats on the host
+
+`external_acl_type` executes the helper locally inside the Squid environment; it does not make an HTTP request to Flask running on the host. Therefore, the Squid container must have access to:
+
+- The Python executable and its dependencies.
+- The helper code and the SquidStats modules it imports.
+- The corresponding `.env` file.
+- The same database, or connectivity to the host database.
+
+If the host application generates the configuration that is later copied into the container, set the paths that exist inside the container before regenerating the block:
+
+```dotenv
+SQUIDSTATS_HELPER_PYTHON=/usr/bin/python3
+SQUIDSTATS_HELPER_PATH=/opt/squidstats-helper/services/captive_portal/helper/captive_portal_helper.py
+```
+
+These variables only change the paths written to `squid.conf`; they do not copy files or install dependencies. Mount the code and database at those paths, install the Python dependencies inside the container, and test from there:
+
+```sh
+docker exec -it squid /usr/bin/python3 \
+  /opt/squidstats-helper/services/captive_portal/helper/captive_portal_helper.py
+```
+
+Type an IP followed by Enter and confirm that it returns `OK` or `ERR`. If the helper uses SQLite, the mounted file must be the same database updated by SquidStats; two SQLite copies will make sessions appear to be missing.
+
 ## 10. Firewall redirection with iptables
 
 The following is an example for a Linux gateway where:

+ 26 - 1
docs/captive_portal/README_es.md

@@ -65,7 +65,7 @@ Prepara lo siguiente:
 - El entorno virtual y el código de SquidStats disponibles para el helper.
 - La base de datos migrada hasta `014_add_captive_portal`.
 - Conectividad LDAP o Active Directory desde SquidStats.
-- Una URL pública o un nombre DNS interno para el portal, por ejemplo `https://portal.example.net`.
+- Una URL pública o un nombre DNS interno para el portal, por ejemplo `https://portal.example.net:5000`.
 - Un firewall o router donde se pueda aislar la VLAN de clientes de la red de administración.
 - DNS y DHCP disponibles para clientes no autenticados.
 - Un certificado TLS si el portal se sirve por HTTPS.
@@ -240,6 +240,31 @@ Si el helper está en un host de Squid separado:
 
 El helper no debe imprimir logs en stdout. Squid utiliza stdout para el protocolo de ACL. Los diagnósticos deben ir a stderr o al log de la aplicación.
 
+### Squid en un contenedor y SquidStats en el host
+
+`external_acl_type` ejecuta el helper localmente dentro del entorno de Squid; no realiza una llamada HTTP al Flask que corre en el host. Por tanto, el contenedor de Squid debe tener disponibles:
+
+- El ejecutable de Python y sus dependencias.
+- El código del helper y los módulos de SquidStats que importa.
+- El archivo `.env` correspondiente.
+- La misma base de datos, o conectividad hacia la misma base de datos del host.
+
+Si la aplicación del host genera la configuración que después se copia al contenedor, define las rutas que existen dentro del contenedor antes de volver a generar el bloque:
+
+```dotenv
+SQUIDSTATS_HELPER_PYTHON=/usr/bin/python3
+SQUIDSTATS_HELPER_PATH=/opt/squidstats-helper/services/captive_portal/helper/captive_portal_helper.py
+```
+
+Estas variables solo cambian las rutas escritas en `squid.conf`; no copian archivos ni instalan dependencias. Monta el código y la base de datos en esas rutas, instala las dependencias Python dentro del contenedor y prueba allí mismo:
+
+```sh
+docker exec -it squid /usr/bin/python3 \
+  /opt/squidstats-helper/services/captive_portal/helper/captive_portal_helper.py
+```
+
+Escribe una IP seguida de Enter y confirma que responde `OK` o `ERR`. Si el helper usa SQLite, el archivo montado debe ser el mismo que actualiza SquidStats; dos copias del archivo SQLite producirán sesiones aparentemente inexistentes.
+
 ## 10. Redirección del firewall con iptables
 
 El siguiente ejemplo supone un gateway Linux donde: