Skip to content
This repository was archived by the owner on Nov 2, 2024. It is now read-only.

Commit d678445

Browse files
agnoranceUbuntu
authored andcommitted
Start with --traefik/--traefik_local option. Closes intelowlproject#2305 (intelowlproject#2351)
* add traefik config and options for dev and prod working config with traefik finish traefik config prod/dev add documentation * Update traefik_local.override.yml - remove comment * rework prod/local traefik and add deletion of get-docker.sh * split traefik compose into base, prod and local * remove print of compose files * parent c45c84a author David Mihajlovic <[email protected]> 1716908101 +0200 committer David Mihajlovic <[email protected]> 1717135119 +0200 add traefik config and options for dev and prod working config with traefik finish traefik config prod/dev add documentation Vulners#1257 (intelowlproject#2340) * vulners * vulners wrapper * docs * lesser variables * migrations * code quality * migration * code --------- Co-authored-by: g4ze <[email protected]> bump 6.0.3 updated docs Bump django-ses from 4.0.0 to 4.1.0 in /requirements (intelowlproject#2342) Bumps [django-ses](https://github.com/django-ses/django-ses) from 4.0.0 to 4.1.0. - [Release notes](https://github.com/django-ses/django-ses/releases) - [Changelog](https://github.com/django-ses/django-ses/blob/main/CHANGES.md) - [Commits](django-ses/django-ses@v4.0.0...v4.1.0) --- updated-dependencies: - dependency-name: django-ses dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> rework prod/local traefik and add deletion of get-docker.sh split traefik compose into base, prod and local get-docker.sh deletion without sudo change traefik compose naming * remove unnecessary files * remove print of compose files * change doc --------- Co-authored-by: Ubuntu <[email protected]>
1 parent 38576b2 commit d678445

File tree

9 files changed

+144
-47
lines changed

9 files changed

+144
-47
lines changed

docker/default.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ services:
6363
- ../configuration/nginx/locations.conf:/etc/nginx/locations.conf
6464
- nginx_logs:/var/log/nginx
6565
- static_content:/var/www/static
66-
ports:
67-
- "80:80"
6866
depends_on:
6967
uwsgi:
7068
condition: service_healthy

docker/nginx.override.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
services:
2+
nginx:
3+
ports:
4+
- "80:80"

docker/traefik.override.yml

Lines changed: 0 additions & 36 deletions
This file was deleted.

docker/traefik.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
services:
2+
traefik:
3+
image: "traefik:3.0"
4+
labels:
5+
- "traefik.enable=true"
6+
7+
nginx:
8+
depends_on:
9+
- traefik
10+
labels:
11+
- "traefik.enable=true"
12+
- "traefik.http.services.nginx.loadbalancer.server.port=80"
13+
expose:
14+
- "80"
15+

docker/traefik_local.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
services:
2+
traefik:
3+
container_name: "intelowl_traefik_local"
4+
command:
5+
# Pleases refer to the official documentation: https://doc.traefik.io/traefik/
6+
# LOGS
7+
- "--log.level=DEBUG"
8+
# DASHBOARD
9+
- "--api.insecure=true"
10+
- "--api.dashboard=true"
11+
# ENTRYPOINTS - redirect every request to use HTTPS
12+
- "--entrypoints.web.address=:80"
13+
# PROVIDERS
14+
- "--providers.docker=true"
15+
- "--providers.docker.watch=true"
16+
- "--providers.docker.exposedbydefault=false"
17+
ports:
18+
- "80:80"
19+
- "8080:8080"
20+
volumes:
21+
- "/var/run/docker.sock:/var/run/docker.sock:ro"
22+
23+
nginx:
24+
depends_on:
25+
- traefik
26+
labels:
27+
- "traefik.http.routers.nginx.rule=Host(`localhost`)"
28+
- "traefik.http.routers.nginx.entrypoints=web"

docker/traefik_prod.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
services:
2+
traefik:
3+
container_name: "intelowl_traefik_prod"
4+
command:
5+
# Pleases refer to the official documentation: https://doc.traefik.io/traefik/
6+
# LOGS - may be omitted if you don't need logs
7+
- "--accesslog=true"
8+
- "--accesslog.filepath=/var/log/traefik/access.log"
9+
- "--log.filePath=/var/log/traefik/traefik.log"
10+
- "--log.level=DEBUG"
11+
# DASHBOARD
12+
- "--api.dashboard=true"
13+
# PROVIDERS
14+
- "--providers.docker=true"
15+
- "--providers.docker.watch=true"
16+
- "--providers.docker.exposedbydefault=false"
17+
# ENTRYPOINTS - redirect every request to use HTTPS
18+
- "--entrypoints.web.address=:80"
19+
- "--entryPoints.web.http.redirections.entryPoint.to=websecure"
20+
- "--entryPoints.web.http.redirections.entryPoint.scheme=https"
21+
- "--entryPoints.web.http.redirections.entrypoint.permanent=true"
22+
- "--entrypoints.websecure.address=:443"
23+
# CERTIFICATE RESOLVERS
24+
- "--certificatesresolvers.le.acme.httpchallenge=true"
25+
- "--certificatesresolvers.le.acme.httpchallenge.entrypoint=web"
26+
# DEV - use this for testing purposes or else you might get blocked - # CHANGE THIS
27+
- "--certificatesresolvers.le.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory"
28+
# PROD - use this if everything works fine - # CHANGE THIS
29+
#- "--certificatesresolvers.le.acme.caserver=https://acme-v02.api.letsencrypt.org/directory"
30+
- "[email protected]" # CHANGE THIS
31+
- "--certificatesresolvers.le.acme.storage=/etc/letsencrypt/acme.json"
32+
labels:
33+
# DASHBOARD - setup for secure dashboard access
34+
- "traefik.http.routers.dashboard.rule=Host(`traefik.intelowl.example.com`) && (PathPrefix(`/api`) || PathPrefix(`/dashboard`))" # CHANGE THIS (Only "Host"!)
35+
- "traefik.http.routers.dashboard.service=api@internal"
36+
- "traefik.http.routers.dashboard.entrypoints=websecure"
37+
- "traefik.http.routers.dashboard.tls=true"
38+
- "traefik.http.routers.dashboard.tls.certresolver=le"
39+
# auth/ipallowlist middlewares allow to limit/secure access - may be omitted
40+
# Here you may define which IPs/CIDR ranges are allowed to access this resource - may be omitted
41+
# - "traefik.http.routers.dashboard.middlewares=dashboard-ipallowlist"
42+
# - "traefik.http.middlewares.dashboard-ipallowlist.ipallowlist.sourcerange=0.0.0.0" # CHANGE THIS
43+
# You can create a new user and password for basic auth with this command:
44+
# echo $(htpasswd -nbB user password) | sed -e s/\\$/\\$\\$/g
45+
# - "traefik.http.routers.dashboard.middlewares=auth"
46+
# - "traefik.http.middlewares.auth.basicauth.users=user:$$2y$$05$$v.ncVNXEJriELglCBEZJmu5I1VrhyhuaVCXATRQTUVuvOF1qgYwpa" # CHANGE THIS (default is user:password)
47+
- "traefik.http.services.dashboard.loadbalancer.server.port=8080"
48+
ports:
49+
- "80:80"
50+
- "443:443"
51+
volumes:
52+
- "/var/run/docker.sock:/var/run/docker.sock:ro"
53+
- "/etc/letsencrypt:/etc/letsencrypt"
54+
- "/var/log/traefik:/var/log/traefik"
55+
56+
nginx:
57+
depends_on:
58+
- traefik
59+
labels:
60+
- "traefik.http.routers.nginx.rule=Host(`intelowl.example.com`)" # CHANGE THIS
61+
- "traefik.http.routers.nginx.entrypoints=websecure"
62+
- "traefik.http.routers.nginx.tls=true"
63+
- "traefik.http.routers.nginx.tls.certresolver=le"
64+
# Here you may define which IPs/CIDR ranges are allowed to access this resource
65+
# - "traefik.http.routers.nginx.middlewares=nginx-ipallowlist"
66+
# - "traefik.http.middlewares.nginx-ipallowlist.ipallowlist.sourcerange=0.0.0.0" # CHANGE THIS

docs/source/Installation.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,12 @@ There are 3 options to execute the web server:
185185

186186
We provide a specific docker-compose file that leverages [Traefik](https://docs.traefik.io/) to allow fast deployments of public-faced and HTTPS-enabled applications.
187187

188-
Before using it, you should configure the configuration file `docker/traefik.override.yml` by changing the email address and the hostname where the application is served. For a detailed explanation follow the official documentation: [Traefix doc](https://docs.traefik.io/user-guides/docker-compose/acme-http/).
188+
Before using the production deployment, you should change the configuration file `docker/traefik_prod.yml` by customising every line which has a "# CHANGE THIS" comment appended to reflect your environment. For a detailed explanation follow the official documentation: [Traefix doc](https://doc.traefik.io/traefik/).
189+
190+
The development deployment is ready to go and running on localhost.
189191

190-
After the configuration is done, you can add the option `--traefik` while executing [`./start`](#run)
192+
After the configuration is done, you can add the option `--traefik_prod` for a production ready deployment while executing [`./start`](#run)
193+
If you just want to test things out you can add the option `--traefik_local` for a development deployment.
191194

192195
## Run
193196

initialize.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ if ! [ -x "$(command -v docker)" ]; then
7676
echo 'Error: Could not install docker.' >&2
7777
exit 1
7878
fi
79+
rm get-docker.sh
7980
else
8081
echo 'You chose to do not install Docker. Exiting'
8182
exit 1

start

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ declare -A env_arguments=(["prod"]=1 ["test"]=1 ["ci"]=1)
99
declare -A test_mode=(["test"]=1 ["ci"]=1)
1010
declare -A cmd_arguments=(["build"]=1 ["up"]=1 ["start"]=1 ["restart"]=1 ["down"]=1 ["stop"]=1 ["kill"]=1 ["logs"]=1 ["ps"]=1)
1111

12-
declare -A path_mapping=(["default"]="docker/default.yml" ["postgres"]="docker/postgres.override.yml" ["rabbitmq"]="docker/rabbitmq.override.yml" ["test"]="docker/test.override.yml" ["ci"]="docker/ci.override.yml" ["custom"]="docker/custom.override.yml" ["traefik"]="docker/traefik.override.yml" ["multi_queue"]="docker/multi-queue.override.yml" ["test_multi_queue"]="docker/test.multi-queue.override.yml" ["flower"]="docker/flower.override.yml" ["test_flower"]="docker/test.flower.override.yml" ["elastic"]="docker/elasticsearch.override.yml" ["https"]="docker/https.override.yml" ["nfs"]="docker/nfs.override.yml")
13-
12+
declare -A path_mapping=(["default"]="docker/default.yml" ["postgres"]="docker/postgres.override.yml" ["rabbitmq"]="docker/rabbitmq.override.yml" ["test"]="docker/test.override.yml" ["ci"]="docker/ci.override.yml" ["custom"]="docker/custom.override.yml" ["traefik"]="docker/traefik.yml" ["traefik_prod"]="docker/traefik_prod.yml" ["traefik_local"]="docker/traefik_local.yml" ["multi_queue"]="docker/multi-queue.override.yml" ["test_multi_queue"]="docker/test.multi-queue.override.yml" ["flower"]="docker/flower.override.yml" ["test_flower"]="docker/test.flower.override.yml" ["elastic"]="docker/elasticsearch.override.yml" ["https"]="docker/https.override.yml" ["nfs"]="docker/nfs.override.yml" ["nginx_default"]="docker/nginx.override.yml")
1413
print_synopsis () {
1514
echo "SYNOPSIS"
1615
echo -e " start <env> <command> [OPTIONS]"
@@ -38,7 +37,8 @@ print_help () {
3837
echo " file."
3938
echo " --multi_queue Uses the multiqueue.override.yml compose file."
4039
echo " --nfs Uses the nfs.override.yml compose file."
41-
echo " --traefik Uses the traefik.override.yml compose file."
40+
echo " --traefik_prod Uses the traefik.yml and traefik_prod.yml compose file."
41+
echo " --traefik_local Uses the traefik.yml and traefik_local.yml compose file."
4242
echo " --use-external-database Do NOT use postgres.override.yml compose file."
4343
echo " --use-external-redis Do NOT use redis.override.yml compose file."
4444
echo " --rabbitmq Uses the rabbitmq.override.yml compose file."
@@ -101,7 +101,8 @@ current_version=${REACT_APP_INTELOWL_VERSION/"v"/""}
101101

102102
docker_analyzers=("pcap_analyzers" "tor_analyzers" "malware_tools_analyzers" "cyberchef" "phoneinfoga")
103103

104-
declare -A path_mapping=(["default"]="docker/default.yml" ["postgres"]="docker/postgres.override.yml" ["rabbitmq"]="docker/rabbitmq.override.yml" ["test"]="docker/test.override.yml" ["ci"]="docker/ci.override.yml" ["custom"]="docker/custom.override.yml" ["traefik"]="docker/traefik.override.yml" ["multi_queue"]="docker/multi-queue.override.yml" ["test_multi_queue"]="docker/test.multi-queue.override.yml" ["flower"]="docker/flower.override.yml" ["test_flower"]="docker/test.flower.override.yml" ["elastic"]="docker/elasticsearch.override.yml" ["https"]="docker/https.override.yml" ["nfs"]="docker/nfs.override.yml" ["redis"]="docker/redis.override.yml")
104+
declare -A path_mapping=(["default"]="docker/default.yml" ["postgres"]="docker/postgres.override.yml" ["rabbitmq"]="docker/rabbitmq.override.yml" ["test"]="docker/test.override.yml" ["ci"]="docker/ci.override.yml" ["custom"]="docker/custom.override.yml" ["traefik"]="docker/traefik.yml" ["traefik_prod"]="docker/traefik_prod.yml" ["traefik_local"]="docker/traefik_local.yml" ["multi_queue"]="docker/multi-queue.override.yml" ["test_multi_queue"]="docker/test.multi-queue.override.yml" ["flower"]="docker/flower.override.yml" ["test_flower"]="docker/test.flower.override.yml" ["elastic"]="docker/elasticsearch.override.yml" ["https"]="docker/https.override.yml" ["nfs"]="docker/nfs.override.yml" ["redis"]="docker/redis.override.yml")
105+
105106
for value in "${docker_analyzers[@]}"; do
106107
path_mapping["${value}"]+="integrations/${value}/compose.yml"
107108
path_mapping["${value}.test"]+="integrations/${value}/compose-tests.yml"
@@ -215,8 +216,12 @@ while [[ $# -gt 0 ]]; do
215216
params["https"]=true
216217
shift 1
217218
;;
218-
--traefik)
219-
params["traefik"]=true
219+
--traefik_prod)
220+
params["traefik_prod"]=true
221+
shift 1
222+
;;
223+
--traefik_local)
224+
params["traefik_local"]=true
220225
shift 1
221226
;;
222227
-h | --help)
@@ -271,12 +276,24 @@ if [ "$is_test" = true ]; then
271276
compose_files+=("${path_mapping["$env_argument"]}")
272277
fi
273278

279+
# Check for the traefik_prod or traefik_local argument and include traefik base compose
280+
if [ "${params["traefik_prod"]}" ] || [ "${params["traefik_local"]}" ]; then
281+
compose_files+=("${path_mapping["traefik"]}")
282+
traefik_enabled=true
283+
fi
284+
285+
# Add the default nginx configuration if traefik is not used
286+
if [ "$traefik_enabled" = false ]; then
287+
compose_files+=("${path_mapping["nginx_default"]}")
288+
fi
289+
274290
# add all the other ones
275291
for value in "${!params[@]}"; do
276292
if [ "${params[$value]}" ]; then
277293
compose_files+=("${path_mapping["$value"]}")
278294
fi
279295
done
296+
280297
# add all the test files
281298
if [[ $env_argument == "test" ]]; then
282299
test_values=("multi_queue" "flower")
@@ -330,8 +347,9 @@ for value in "${compose_files[@]}" ; do
330347
to_run+=" -f $value"
331348
fi
332349
done
350+
333351
if grep "docker" <<< "$(groups)" > /dev/null 2>&1; then
334352
docker compose --project-directory docker ${to_run[@]} -p "$project_name" "$cmd_argument" "$@"
335353
else
336354
sudo docker compose --project-directory docker ${to_run[@]} -p "$project_name" "$cmd_argument" "$@"
337-
fi
355+
fi

0 commit comments

Comments
 (0)