diff --git a/hermes_squid/nginx-hermes.conf b/hermes_squid/nginx-hermes.conf new file mode 100644 index 0000000..4f97cdc --- /dev/null +++ b/hermes_squid/nginx-hermes.conf @@ -0,0 +1,21 @@ +map $http_upgrade $connection_upgrade { + default upgrade; + '' close; +} + +server { + listen 8087; + server_name _; + + location / { + proxy_pass http://hermes-gateway:9119; + proxy_http_version 1.1; + 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 X-Forwarded-Proto $scheme; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; + proxy_read_timeout 3600s; + } +} diff --git a/hermes_squid/sarg-minute.cron b/hermes_squid/sarg-minute.cron new file mode 100644 index 0000000..57db4ac --- /dev/null +++ b/hermes_squid/sarg-minute.cron @@ -0,0 +1 @@ +* * * * * root /usr/sbin/sarg -l /var/log/squid/access.log -o /www -x >/dev/null 2>&1 diff --git a/hermes_squid/sarg.conf b/hermes_squid/sarg.conf new file mode 100644 index 0000000..a729d6d --- /dev/null +++ b/hermes_squid/sarg.conf @@ -0,0 +1,4 @@ +access_log /var/log/squid/access.log +output_dir /www +overwrite_report yes +index yes diff --git a/hermes_squid/squid.conf b/hermes_squid/squid.conf new file mode 100644 index 0000000..2cbea84 --- /dev/null +++ b/hermes_squid/squid.conf @@ -0,0 +1,17 @@ +acl hermes_network src 10.0.0.0/8 +acl hermes_network src 172.16.0.0/12 +acl hermes_network src 192.168.0.0/16 +acl allowed_domains dstdomain .minimax.io .minimax.chat .minimax.com .githubusercontent.com deb.debian.org +acl CONNECT method CONNECT +acl SSL_ports port 443 +acl Safe_ports port 80 443 + +http_access deny !Safe_ports +http_access deny CONNECT !SSL_ports +http_access allow hermes_network allowed_domains +http_access deny all + +http_port 3128 +access_log stdio:/var/log/squid/access.log +cache_dir ufs /var/spool/squid 100 16 256 +coredump_dir /var/spool/squid diff --git a/hermes_squid/stack-compose.yml b/hermes_squid/stack-compose.yml new file mode 100644 index 0000000..af9d619 --- /dev/null +++ b/hermes_squid/stack-compose.yml @@ -0,0 +1,130 @@ +version: "3.9" + +services: + squid: + image: ubuntu/squid:latest + hostname: squid + networks: + - hermes_proxy + - squid_egress + ports: + - target: 3128 + published: 3128 + protocol: tcp + volumes: + - ./squid.conf:/etc/squid/squid.conf:ro + - squid_cache:/var/spool/squid + - squid_logs:/var/log/squid + environment: + TZ: UTC + deploy: + replicas: 1 + restart_policy: + condition: on-failure + + sarg: + image: starina/squid-sarg-cron:latest + hostname: sarg + networks: + - admin + ports: + - target: 80 + published: 8090 + protocol: tcp + volumes: + - squid_logs:/var/log/squid:ro + - squid_reports:/www + - ./sarg.conf:/etc/sarg/sarg.conf:ro + deploy: + replicas: 1 + placement: + constraints: + - node.hostname == rudolf-T + restart_policy: + condition: on-failure + + hermes-gateway: + image: nousresearch/hermes-agent:latest + command: gateway run + networks: + - hermes_proxy + volumes: + - hermes_gateway_data:/opt/data + environment: + HERMES_DASHBOARD: "1" + HERMES_DASHBOARD_HOST: "0.0.0.0" + HERMES_DASHBOARD_BASIC_AUTH_USERNAME: admin + HERMES_DASHBOARD_BASIC_AUTH_PASSWORD: admin + HERMES_AGENT_URL: http://hermes-agent:8000 + HTTP_PROXY: http://squid:3128 + HTTPS_PROXY: http://squid:3128 + http_proxy: http://squid:3128 + https_proxy: http://squid:3128 + NO_PROXY: localhost,127.0.0.1,squid,hermes-gateway,hermes-agent + no_proxy: localhost,127.0.0.1,squid,hermes-gateway,hermes-agent + depends_on: + - squid + deploy: + replicas: 1 + restart_policy: + condition: on-failure + + hermes-ui: + image: nginx:alpine + hostname: hermes-ui + networks: + - hermes_proxy + ports: + - target: 8087 + published: 8087 + protocol: tcp + volumes: + - ./nginx-hermes.conf:/etc/nginx/conf.d/default.conf:ro + depends_on: + - hermes-gateway + deploy: + replicas: 1 + restart_policy: + condition: on-failure + + # hermes-agent: + # image: nousresearch/hermes-agent:latest + # command: sleep infinity + # networks: + # - hermes_proxy + # volumes: + # - hermes_agent_data:/opt/data + # environment: + # TELEGRAM_HOME_CHANNEL_NAME: Default + # HERMES_GATEWAY_URL: http://hermes-gateway:8000 + # HTTP_PROXY: http://squid:3128 + # HTTPS_PROXY: http://squid:3128 + # http_proxy: http://squid:3128 + # https_proxy: http://squid:3128 + # NO_PROXY: localhost,127.0.0.1,squid,hermes-gateway,hermes-agent + # no_proxy: localhost,127.0.0.1,squid,hermes-gateway,hermes-agent + # depends_on: + # - squid + # deploy: + # replicas: 1 + # restart_policy: + # condition: on-failure + +networks: + hermes_proxy: + driver: overlay + attachable: true + internal: true + squid_egress: + driver: overlay + admin: + driver: overlay + attachable: true + +volumes: + squid_etc: + squid_cache: + squid_logs: + squid_reports: + hermes_gateway_data: + hermes_agent_data: