Skip to content

Commit 83415c1

Browse files
authored
Merge pull request #171 from json-scada/master
Add Dozzle to monitor logs on Docker Demo.
2 parents cb9f327 + 19737b4 commit 83415c1

File tree

2 files changed

+34
-10
lines changed

2 files changed

+34
-10
lines changed

demo-docker/docker-compose.yaml

+20-3
Original file line numberDiff line numberDiff line change
@@ -274,23 +274,22 @@ services:
274274
- JS_IP_BIND=0.0.0.0
275275
- JS_HTTP_PORT=8080
276276
- JS_GRAFANA_SERVER=http://grafana:3000
277+
- JS_LOGIO_SERVER=http://dozzle:6688
277278
- PGPORT=5432
278279
- PGHOST=jsdemo_timescaledb
279280
- PGDATABASE=json_scada
280281
- PGUSER=json_scada
281282
- PGPASSWORD=
282283
volumes:
283284
- ../src/server_realtime_auth:/server_realtime_auth
284-
#- ../src/htdocs:/htdocs
285-
#- ../src/htdocs-admin:/htdocs-admin
286-
#- ../src/htdocs-login:/htdocs-login
287285
- ../src/AdminUI:/AdminUI
288286
- ../svg:/svg
289287
- ./conf:/conf
290288
- ./log:/log
291289
links:
292290
- jsdemo_mongorsn1
293291
- grafana
292+
- dozzle
294293
# exports the HTTP port to the main host
295294
ports:
296295
- 8080:8080
@@ -400,6 +399,24 @@ services:
400399
networks:
401400
- jsdemo_net
402401

402+
# monitoring of logs of the docker containers
403+
dozzle:
404+
container_name: dozzle
405+
image: amir20/dozzle:latest
406+
volumes:
407+
- /var/run/docker.sock:/var/run/docker.sock
408+
environment:
409+
- DOZZLE_ADDR=0.0.0.0:6688
410+
- DOZZLE_BASE=/log-io
411+
- DOZZLE_NO_ANALYTICS=true
412+
# - DOZZLE_LEVEL=debug
413+
ports:
414+
- 6688:6688
415+
expose:
416+
- "6688"
417+
networks:
418+
- jsdemo_net
419+
403420
networks:
404421
jsdemo_net:
405422
driver: bridge

src/server_realtime_auth/app/routes/user.routes.js

+14-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
const path = require('path')
21
const express = require('express')
32
const httpProxy = require('express-http-proxy')
4-
const { legacyCreateProxyMiddleware: createProxyMiddleware } = require('http-proxy-middleware');
3+
const {
4+
legacyCreateProxyMiddleware: createProxyMiddleware,
5+
} = require('http-proxy-middleware')
56
const { authJwt } = require('../middlewares')
67
const controller = require('../controllers/user.controller')
78
const authController = require('../controllers/auth.controller')
@@ -61,15 +62,21 @@ module.exports = function (
6162
httpProxy(metabaseServer)
6263
)
6364

64-
// reverse proxy for log.io
65+
// reverse proxy for log.io on Windows
66+
// for docker it will be used Dozzle
6567
app.use(
6668
'/log-io',
6769
[authJwt.verifyToken],
6870
function (req, _, next) {
6971
authController.addXWebAuthUser(req)
7072
next()
7173
},
72-
httpProxy(logioServer)
74+
logioServer.indexOf('//dozzle') === -1
75+
? httpProxy(logioServer)
76+
: createProxyMiddleware({
77+
target: logioServer,
78+
changeOrigin: true,
79+
})
7380
)
7481
const wsProxy = createProxyMiddleware({
7582
target: logioServer,
@@ -86,7 +93,7 @@ module.exports = function (
8693
wsProxy
8794
)
8895
app.on('upgrade', wsProxy.upgrade)
89-
app.use('/static', express.static('../log-io/ui/build/static'));
96+
app.use('/static', express.static('../log-io/ui/build/static'))
9097

9198
app.post(accessPoint, opcApi) // realtime data API
9299

@@ -101,15 +108,15 @@ module.exports = function (
101108
)
102109

103110
app.get(accessPoint + 'test/admin', [authJwt.isAdmin], controller.adminBoard)
104-
111+
105112
app.use('/svg', [authJwt.verifyToken], express.static('../../svg'))
106113

107114
// production
108115
app.use('/', express.static('../AdminUI/dist'))
109116
app.use('/login', express.static('../AdminUI/dist'))
110117
app.use('/dashboard', express.static('../AdminUI/dist'))
111118
app.use('/admin', express.static('../AdminUI/dist'))
112-
119+
113120
// development
114121
//app.use('/', httpProxy('localhost:3000/'))
115122
//app.use('/login', httpProxy('localhost:3000/'))

0 commit comments

Comments
 (0)