Skip to content

Commit e4fec0e

Browse files
authored
Merge pull request #6 from khast3x/dev - Traefik
Traefik now replaces NGINX
2 parents 7ab3bd0 + 98dd9c5 commit e4fec0e

File tree

13 files changed

+240
-144
lines changed

13 files changed

+240
-144
lines changed

README.md

Lines changed: 91 additions & 29 deletions
Large diffs are not rendered by default.

docker-compose.yml

Lines changed: 72 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,85 @@
1-
version: '2'
1+
version: "3"
22

33
services:
44
cert_gen:
5-
image: paulczar/omgwtfssl
6-
volumes:
7-
- /tmp/certs:/certs
8-
9-
proxy:
10-
build: nginx/
11-
container_name: "portainer-proxy"
12-
ports:
13-
- "80:80"
14-
- "443:443"
15-
volumes_from:
16-
- cert_gen
17-
volumes:
18-
- files:/etc/nginx/html/files
19-
restart: on-failure
5+
container_name: "cert-gen"
6+
image: paulczar/omgwtfssl
7+
volumes:
8+
- certs:/certs
9+
labels:
10+
- "traefik.enable=false"
2011

21-
templates:
22-
build : nginx-templates/
23-
container_name: "nginx-templates"
12+
traefik:
13+
build: traefik/
14+
container_name: "traefik"
15+
networks:
16+
- default
17+
- inside
2418
ports:
25-
- "8080:80"
19+
- 80:80
20+
- 443:443
21+
volumes:
22+
- /var/run/docker.sock:/var/run/docker.sock
23+
- certs:/certs
24+
- logs:/logs
25+
labels:
26+
- "traefik.frontend.rule=PathPrefixStrip:/api"
27+
- "traefik.frontend.auth.basic.usersFile=/etc/traefik/.htpasswd"
28+
- "traefik.port=8081"
29+
30+
31+
32+
33+
templates:
34+
build : templates/
35+
container_name: "templates"
2636
networks:
2737
- inside
38+
labels:
39+
- "traefik.enable=false"
2840

41+
public-files:
42+
image: aikain/simplehttpserver:0.1
43+
container_name: "public-files"
44+
volumes:
45+
- files:/var/www/
46+
- logs:/var/www/logs
47+
networks:
48+
- inside
49+
labels:
50+
- "traefik.sec.frontend.rule=PathPrefixStrip:/files/logs"
51+
- "traefik.sec.port=80"
52+
- "traefik.sec.frontend.auth.basic.users=admin:$$apr1$$JWufnu2u$$jK16K8EczmfIBDk5p3xw6/"
53+
- "traefik.nosec.frontend.rule=PathPrefixStrip:/files"
54+
- "traefik.nosec.port=80"
55+
56+
2957
portainer:
30-
image: portainer/portainer
31-
container_name: "portainer-app"
32-
command: --host=unix:///var/run/docker.sock --logo "https://i.imgur.com/lwVlWt2.jpg" --templates "http://nginx-templates/templates.yml"
33-
volumes:
34-
- /var/run/docker.sock:/var/run/docker.sock
35-
- /opt/portainer/data:/data
36-
networks:
37-
- default
38-
- inside
39-
40-
# tester:
41-
# image: nginx:latest
42-
# container_name: "tester"
43-
# networks:
44-
# - default
45-
# - inside
58+
image: portainer/portainer
59+
container_name: "portainer-app"
60+
networks:
61+
- inside
62+
volumes:
63+
- /var/run/docker.sock:/var/run/docker.sock
64+
- /opt/portainer/data:/data
65+
command: --host=unix:///var/run/docker.sock --logo "https://i.imgur.com/lwVlWt2.jpg" --templates "http://templates/templates.yml"
66+
67+
labels:
68+
- "traefik.frontend.rule=PathPrefixStrip:/portainer"
69+
- "traefik.port=9000"
70+
- "traefik.passHostHeader=true"
71+
- "traefik.docker.network=redcloud_inside"
72+
- "traefik.backend.loadbalancer.swarm=true"
73+
- "traefik.backend.loadbalancer.method=drr"
74+
# https://github.com/containous/traefik/issues/563#issuecomment-421360934
75+
- "traefik.frontend.redirect.regex=^(.*)/portainer$$"
76+
- "traefik.frontend.redirect.replacement=$$1/portainer/"
77+
- "traefik.frontend.rule=PathPrefix:/portainer;ReplacePathRegex: ^/portainer/(.*) /$$1"
4678

4779
volumes:
80+
certs:
81+
logs:
4882
files:
49-
5083
networks:
51-
inside:
84+
inside:
85+
external: false

nginx-templates/Dockerfile

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

nginx-templates/config/portainer.conf

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

nginx/Dockerfile

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

nginx/config/portainer.conf

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

redcloud.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
REDCLOUD_INSTALL_GIT = "git clone https://github.com/khast3x/redcloud.git"
1111
REDCLOUD_INSTALL_SCP = "scp -r ../redcloud {target}:~/"
1212
SSH_OR = " || echo \"error\""
13-
GET_IP = "curl -4 icanhazip.com"
13+
GET_IP = "curl -4 -s icanhazip.com"
1414

1515

1616
def print_banner(arg = ""):
@@ -79,7 +79,7 @@ def list_available():
7979
'''
8080
import yaml
8181

82-
with open("nginx-templates/templates.yml", 'r') as stream:
82+
with open("templates/templates.yml", 'r') as stream:
8383
try:
8484
data = yaml.load(stream)
8585
for templ in data:
@@ -96,6 +96,8 @@ def install_docker(prefix = ""):
9696
Runs the command to install docker. Can run with the SSH prefix to install remotly
9797
Keep both seperated for later debugging
9898
'''
99+
c.info_news(c, "This might take a few minutes... Hang in there!")
100+
99101
if len(prefix) != 0:
100102
output = run_cmd_output(prefix + DOCKER_INSTALL)
101103
else:
@@ -144,6 +146,7 @@ def deploy_local():
144146
c.bad_news(c, "docker-compose installation not found")
145147
c.question_news(c, "Install docker-compose? [Y/n]")
146148
dockerq = input(">> ")
149+
print(dockerq)
147150
if dockerq == "n":
148151
c.info_news(c, "Skipping...")
149152
else:
@@ -163,11 +166,14 @@ def deploy_local():
163166

164167
# Start deploy
165168
c.good_news(c, "Deploying redcloud")
166-
run_cmd_output(DOCKER_DEPLOY)
169+
output = run_cmd_output(DOCKER_DEPLOY)
170+
print(output)
167171
c.good_news(c, "Done")
168172
ip = run_cmd_output(GET_IP)
169173
print(c.bold + c.fg.green + "\n" + "=========================================================================" + c.reset)
170174
c.good_news(c, "Please find your running instance at https://" + ip +"/portainer")
175+
c.info_news(c, "Files are available at https://" + ip + "/files")
176+
c.info_news(c, "Live Reverse Proxy data is available at https://" + ip + "/api")
171177
print(c.bold + c.fg.green + "=========================================================================" + c.reset)
172178
print(c.bg.orange + "\n" + c.reset)
173179
input("\n- Press Enter to continue -")
@@ -248,6 +254,8 @@ def deploy_remote_ssh():
248254
ip = run_cmd_output(SSH_CMD + GET_IP)
249255
print(c.bold + c.fg.green + "\n" + "=========================================================================" + c.reset)
250256
c.good_news(c, "Please find your running instance at https://" + ip +"/portainer")
257+
c.info_news(c, "Files are available at https://" + ip + "/files")
258+
c.info_news(c, "Live reverse proxy data is available at https://" + ip + "/api")
251259
print(c.bold + c.fg.green + "=========================================================================" + c.reset)
252260
print(c.bg.purple + "\n" + c.reset)
253261
input("\n- Press Enter to continue -")
@@ -314,6 +322,8 @@ def deploy_dockermachine():
314322
ip = os.environ['DOCKER_HOST']
315323
print(c.bold + c.fg.green + "\n" + "=========================================================================" + c.reset)
316324
c.good_news(c, "Please find your running instance at https:" + ip.split(":")[1] +"/portainer")
325+
c.info_news(c, "Files are available at https:" + ip.split(":")[1] + "/files")
326+
c.info_news(c, "Live reverse proxy data is available at https:" + ip.split(":")[1] + "/api")
317327
print(c.bold + c.fg.green + "=========================================================================" + c.reset)
318328
print(c.bg.cyan + "\n" + c.reset)
319329
input("\n- Press Enter to continue -")

templates/Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM aikain/simplehttpserver:0.1
2+
COPY templates.yml /var/www/
3+
4+
CMD python3 -m http.server 80
Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
"image": "phocean/msf",
2828
"restart_policy": "unless-stopped",
2929
"categories": ["offensive", "database", "stack"],
30+
"labels": [
31+
{ "name": "traefik.frontend.rule", "value": "PathPrefixStrip:/msf" },
32+
{ "name": "traefik.port", "value": "4444" }
33+
],
3034
"ports": [
3135
"4444:4444/tcp"
3236
]
@@ -46,7 +50,12 @@
4650
"categories": ["offensive"],
4751
"ports": [
4852
"5555:5555/tcp"
53+
],
54+
"labels": [
55+
{ "name": "traefik.frontend.rule", "value": "PathPrefixStrip:/empire" },
56+
{ "name": "traefik.port", "value": "5555" }
4957
]
58+
5059
},
5160
{
5261
"type": 1,
@@ -105,7 +114,7 @@
105114
]
106115
},
107116
{
108-
"type": 1,
117+
"type": 1,
109118
"platform": "linux",
110119
"network": "redcloud_default",
111120
"title": "Kali - Full",
@@ -161,14 +170,14 @@
161170
"description": "Open-Source Phishing Toolkit",
162171
"name": "red_gophish",
163172
"logo": "https://i.imgur.com/l21Rn2v.png",
164-
"note": "In your browser, head over to https://your-docker-machine-ip:3333. Don't forget the S in https",
173+
"note": "In your browser, head over to https://your-docker-machine-ip:3333. Don't forget the S in https. Default credentials: admin/gophish",
165174
"image": "matteoggl/gophish",
166175
"restart_policy": "unless-stopped",
167176
"categories": ["offensive", "phishing"],
168177
"ports": [
169178
"3333:3333/tcp",
170179
"8083:80/tcp"
171-
]
180+
]
172181
},
173182
{
174183
"type": 1,
@@ -236,7 +245,7 @@
236245
"ports": [
237246
"5901:5901/tcp",
238247
"6901:6901/tcp"
239-
]
248+
]
240249
},
241250
{
242251
"type": 1,
@@ -252,7 +261,7 @@
252261
"categories": ["vulnerable", "webserver"],
253262
"ports": [
254263
"8082:80/tcp"
255-
]
264+
]
256265
},
257266
{
258267
"type": 1,
@@ -268,7 +277,7 @@
268277
"categories": ["vulnerable", "webserver"],
269278
"ports": [
270279
"8084:3000/tcp"
271-
]
280+
]
272281
},
273282
{
274283
"type": 1,

0 commit comments

Comments
 (0)