forked from plainvan/docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwapp.js
41 lines (31 loc) · 961 Bytes
/
wapp.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const http = require('http');
const os = require('os');
console.log("Tiny http server starting...");
var handler = function(request, response) {
const addr = request.connection.remoteAddress;
const dt = new Date();
response.writeHead(200);
const host_name = os.hostname();
const host_ip = request.connection.localAddress;
console.log(dt + "--> request from: " + addr + " to host: " +host_name);
const dock_host = process.env.DOCK_HOST;
var body =
`<html>
<head>
<title>SITE: ${host_name}</title>
</head>
<body>
<h1>Hello, Andrei!</h1>
<h1>Welcome to docker host: ${dock_host}</h1>
<h2>Container id: ${host_name}</h2>
<h2>Container ip: ${host_ip}</h2>
<div style="color:green;">
<h3>Accessed from: ${addr} </h3>
<h3>${dt}</h3>
</div>
</body>
</html>`;
response.end(body);
};
var www = http.createServer(handler);
www.listen(8080);