From 5fd0d158e67036c7527f23079d6ff162e563f521 Mon Sep 17 00:00:00 2001 From: t3chn0m4g3 Date: Thu, 27 Apr 2023 18:42:38 +0200 Subject: [PATCH] Add Nginx Cockpit Awareness --- docker/nginx/Dockerfile | 3 +- docker/nginx/dist/conf/nginx.conf | 8 ++- docker/nginx/dist/conf/tpotweb.conf | 13 +++-- docker/nginx/dist/html/config_light.js | 71 +++++++++++++++++++++++++ docker/nginx/dist/html/index_light.html | 60 +++++++++++++++++++++ docker/nginx/docker-compose.yml | 2 + 6 files changed, 152 insertions(+), 5 deletions(-) create mode 100644 docker/nginx/dist/html/config_light.js create mode 100644 docker/nginx/dist/html/index_light.html diff --git a/docker/nginx/Dockerfile b/docker/nginx/Dockerfile index 57d2831f..b2ed2c5a 100644 --- a/docker/nginx/Dockerfile +++ b/docker/nginx/Dockerfile @@ -7,7 +7,8 @@ COPY dist/ /root/dist/ RUN apk -U --no-cache add \ nginx \ nginx-mod-http-brotli \ - nginx-mod-http-headers-more && \ + nginx-mod-http-headers-more \ + nginx-mod-http-lua && \ # ## Setup T-Pot Landing Page, Eleasticvue, Cyberchef cp -R /root/dist/html/* /var/lib/nginx/html/ && \ diff --git a/docker/nginx/dist/conf/nginx.conf b/docker/nginx/dist/conf/nginx.conf index 1a3abd1c..231273d6 100644 --- a/docker/nginx/dist/conf/nginx.conf +++ b/docker/nginx/dist/conf/nginx.conf @@ -5,6 +5,13 @@ load_module /usr/lib/nginx/modules/ngx_http_headers_more_filter_module.so; load_module /usr/lib/nginx/modules/ngx_http_brotli_filter_module.so; load_module /usr/lib/nginx/modules/ngx_http_brotli_static_module.so; +# OS ENV variables need to be defined here, so Lua can use them +env COCKPIT; + +# Both modules are needed for Lua, in this exact order +load_module /usr/lib/nginx/modules/ndk_http_module.so; +load_module /usr/lib/nginx/modules/ngx_http_lua_module.so; + events { worker_connections 768; # multi_accept on; @@ -15,7 +22,6 @@ http { ## # Basic Settings ## - sendfile on; tcp_nopush on; tcp_nodelay on; diff --git a/docker/nginx/dist/conf/tpotweb.conf b/docker/nginx/dist/conf/tpotweb.conf index 67b079a4..d46369f0 100644 --- a/docker/nginx/dist/conf/tpotweb.conf +++ b/docker/nginx/dist/conf/tpotweb.conf @@ -90,16 +90,23 @@ server { auth_basic "closed site"; auth_basic_user_file /etc/nginx/nginxpasswd; - ############################# ### T-Pot Landing Page & Apps ############################# location / { - index index.html; + set_by_lua_block $index_file { + local cockpit = os.getenv("COCKPIT") + if cockpit == "false" then + return "index_light.html" + else + return "index.html" + end + } auth_basic "closed site"; auth_basic_user_file /etc/nginx/nginxpasswd; - try_files $uri $uri/ /index.html; + index $index_file; + try_files $uri $uri/ /$index_file; } location /elasticvue { diff --git a/docker/nginx/dist/html/config_light.js b/docker/nginx/dist/html/config_light.js new file mode 100644 index 00000000..f1af7436 --- /dev/null +++ b/docker/nginx/dist/html/config_light.js @@ -0,0 +1,71 @@ +// ╔╗ ╔═╗╔╗╔╔╦╗╔═╗ +// ╠╩╗║╣ ║║║ ║ ║ ║ +// ╚═╝╚═╝╝╚╝ ╩ ╚═╝ +// ┌─┐┌─┐┌┐┌┌─┐┬┌─┐┬ ┬┬─┐┌─┐┌┬┐┬┌─┐┌┐┌ +// │ │ ││││├┤ ││ ┬│ │├┬┘├─┤ │ ││ ││││ +// └─┘└─┘┘└┘└ ┴└─┘└─┘┴└─┴ ┴ ┴ ┴└─┘┘└┘ + +const CONFIG = { + // ┌┐ ┌─┐┌─┐┬┌─┐┌─┐ + // ├┴┐├─┤└─┐││ └─┐ + // └─┘┴ ┴└─┘┴└─┘└─┘ + + // General + imageBackground: true, + openInNewTab: true, + twelveHourFormat: false, + + // Greetings + greetingMorning: 'Good morning ☕', + greetingAfternoon: 'Good afternoon 🍯', + greetingEvening: 'Good evening 😁', + greetingNight: 'Go to Sleep 🥱', + + // ┬ ┬┌─┐┌┬┐┌─┐ + // │ │└─┐ │ └─┐ + // ┴─┘┴└─┘ ┴ └─┘ + + //Icons + firstListIcon: 'home', + secondListIcon: 'external-link', + + // Links + lists: { + firstList: [ + { + name: 'Attack Map', + link: '/map/', + }, + { + name: 'Cyberchef', + link: '/cyberchef/', + }, + { + name: 'Elasticvue', + link: '/elasticvue/', + }, + { + name: 'Kibana', + link: '/kibana/', + }, + { + name: 'Spiderfoot', + link: '/spiderfoot/', + }, + ], + secondList: [ + { + name: 'SecurityMeter', + link: 'https://sicherheitstacho.eu', + }, + { + name: 'T-Pot @ GitHub', + link: 'https://github.com/telekom-security/tpotce/', + }, + { + name: 'T-Pot ReadMe', + link: 'https://github.com/telekom-security/tpotce/blob/master/README.md', + }, + ], + }, +}; diff --git a/docker/nginx/dist/html/index_light.html b/docker/nginx/dist/html/index_light.html new file mode 100644 index 00000000..7d92f100 --- /dev/null +++ b/docker/nginx/dist/html/index_light.html @@ -0,0 +1,60 @@ + + + + + T-Pot + + + + + + + + +
+ + +
+
+
+
+
+
+
+
+ + + +
+ +
+
+ + + + + + + + + + + + + + + diff --git a/docker/nginx/docker-compose.yml b/docker/nginx/docker-compose.yml index 74193a08..7e337abe 100644 --- a/docker/nginx/docker-compose.yml +++ b/docker/nginx/docker-compose.yml @@ -5,6 +5,8 @@ services: # nginx service nginx: build: . + environment: + - COCKPIT=false container_name: nginx restart: always tmpfs: