@@ -28,72 +28,78 @@ for path in ['loki_path', 'prometheus_path', 'webssh_path']:
2828 config [path ] = f'/{ uuid .uuid4 ()} '
2929
3030# Configure Traefik to route requests to the nethsec-controller service
31- response = agent .tasks .run (
32- agent_id = agent .resolve_agent_id ('traefik@node' ),
33- action = 'set-route' ,
34- data = {
35- 'instance' : os .environ ['MODULE_ID' ],
36- 'url' : f'http://127.0.0.1:{ ports [3 ]} ' ,
37- 'http2https' : True ,
38- 'lets_encrypt' : request ["lets_encrypt" ],
39- 'host' : request ["host" ],
40- },
41- )
42- agent .assert_exp (response ['exit_code' ] == 0 )
43- response = agent .tasks .run (
44- agent_id = agent .resolve_agent_id ('traefik@node' ),
45- action = 'set-route' ,
46- data = {
47- 'instance' : os .environ ['MODULE_ID' ] + '_grafana' ,
48- 'url' : f'http://127.0.0.1:{ ports [8 ]} ' ,
49- 'http2https' : True ,
50- 'lets_encrypt' : request ["lets_encrypt" ],
51- 'host' : request ["host" ],
52- 'path' : '/grafana'
53- },
54- )
55- agent .assert_exp (response ['exit_code' ] == 0 )
56- response = agent .tasks .run (
57- agent_id = agent .resolve_agent_id ('traefik@node' ),
58- action = 'set-route' ,
59- data = {
60- 'instance' : os .environ ['MODULE_ID' ] + '_loki' ,
61- 'url' : f'http://127.0.0.1:{ ports [5 ]} ' ,
62- 'http2https' : True ,
63- 'lets_encrypt' : request ["lets_encrypt" ],
64- 'host' : request ["host" ],
65- 'path' : config ['loki_path' ]
66- },
67- )
68- agent .assert_exp (response ['exit_code' ] == 0 )
69- response = agent .tasks .run (
70- agent_id = agent .resolve_agent_id ('traefik@node' ),
71- action = 'set-route' ,
72- data = {
73- 'instance' : os .environ ['MODULE_ID' ] + '_prometheus' ,
74- 'url' : f'http://127.0.0.1:{ ports [7 ]} ' ,
75- 'http2https' : True ,
76- 'lets_encrypt' : request ["lets_encrypt" ],
77- 'host' : request ["host" ],
78- 'path' : config ['prometheus_path' ]
79- },
80- )
81- agent .assert_exp (response ['exit_code' ] == 0 )
82-
83- response = agent .tasks .run (
84- agent_id = agent .resolve_agent_id ('traefik@node' ),
85- action = 'set-route' ,
86- data = {
87- 'instance' : os .environ ['MODULE_ID' ] + '_webssh' ,
88- 'url' : f'http://127.0.0.1:{ ports [9 ]} ' ,
89- 'http2https' : True ,
90- 'lets_encrypt' : request ["lets_encrypt" ],
91- 'host' : request ["host" ],
92- 'path' : config ['webssh_path' ],
93- 'strip_prefix' : True
94- },
95- )
96- agent .assert_exp (response ['exit_code' ] == 0 )
31+ set_route_data = {
32+ 'instance' : os .environ ['MODULE_ID' ],
33+ 'url' : f'http://127.0.0.1:{ ports [3 ]} ' ,
34+ 'http2https' : True ,
35+ 'host' : request ["host" ],
36+ 'lets_encrypt_check' : True ,
37+ 'lets_encrypt_cleanup' : True ,
38+ }
39+ if 'lets_encrypt' in request :
40+ set_route_data ['lets_encrypt' ] = request ['lets_encrypt' ]
41+
42+ agent .set_route (set_route_data )
43+
44+ # Configure Traefik to route requests to the grafana service
45+ set_route_data = {
46+ 'instance' : os .environ ['MODULE_ID' ] + '_grafana' ,
47+ 'url' : f'http://127.0.0.1:{ ports [8 ]} ' ,
48+ 'http2https' : True ,
49+ 'host' : request ["host" ],
50+ 'path' : '/grafana' ,
51+ 'lets_encrypt_check' : True ,
52+ 'lets_encrypt_cleanup' : True ,
53+ }
54+ if 'lets_encrypt' in request :
55+ set_route_data ['lets_encrypt' ] = request ['lets_encrypt' ]
56+
57+ agent .set_route (set_route_data )
58+
59+ # Configure Traefik to route requests to the loki service
60+ set_route_data = {
61+ 'instance' : os .environ ['MODULE_ID' ] + '_loki' ,
62+ 'url' : f'http://127.0.0.1:{ ports [5 ]} ' ,
63+ 'http2https' : True ,
64+ 'host' : request ["host" ],
65+ 'path' : config ['loki_path' ],
66+ 'lets_encrypt_check' : True ,
67+ 'lets_encrypt_cleanup' : True ,
68+ }
69+ if 'lets_encrypt' in request :
70+ set_route_data ['lets_encrypt' ] = request ['lets_encrypt' ]
71+
72+ agent .set_route (set_route_data )
73+
74+ # Configure Traefik to route requests to the prometheus service
75+ set_route_data = {
76+ 'instance' : os .environ ['MODULE_ID' ] + '_prometheus' ,
77+ 'url' : f'http://127.0.0.1:{ ports [7 ]} ' ,
78+ 'http2https' : True ,
79+ 'host' : request ["host" ],
80+ 'path' : config ['prometheus_path' ],
81+ 'lets_encrypt_check' : True ,
82+ 'lets_encrypt_cleanup' : True ,
83+ }
84+ if 'lets_encrypt' in request :
85+ set_route_data ['lets_encrypt' ] = request ['lets_encrypt' ]
86+
87+ agent .set_route (set_route_data )
88+
89+ # Configure Traefik to route requests to the webssh service
90+ set_route_data = {
91+ 'instance' : os .environ ['MODULE_ID' ] + '_webssh' ,
92+ 'url' : f'http://127.0.0.1:{ ports [9 ]} ' ,
93+ 'http2https' : True ,
94+ 'lets_encrypt' : request ["lets_encrypt" ],
95+ 'host' : request ["host" ],
96+ 'path' : config ['webssh_path' ],
97+ 'strip_prefix' : True ,
98+ 'lets_encrypt_check' : True ,
99+ 'lets_encrypt_cleanup' : True ,
100+ }
101+ if 'lets_encrypt' in request :
102+ set_route_data ['lets_encrypt' ] = request ['lets_encrypt' ]
97103
98104config ["allowed_ips" ] = request .get ("allowed_ips" , [])
99105
0 commit comments