-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwith_certbot.js
More file actions
56 lines (45 loc) · 1.84 KB
/
Copy pathwith_certbot.js
File metadata and controls
56 lines (45 loc) · 1.84 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
sudo certbot certonly --standalone
www.bluepyrami.de
193.197.228.28
2001:7c0:2330:137:f816:3eff:fe01:9c40
Certificate is saved at: /etc/letsencrypt/live/www.bluepyrami.de/fullchain.pem
Key is saved at: /etc/letsencrypt/live/www.bluepyrami.de/privkey.pem
https://www.bluepyrami.de:8443/
http://www.bluepyrami.de:8080/
*/
/////////////////////////////////////////////////////////////////////////////80
// General Purpose STATIC Web Server
// andreas.roessler@hs-esslingen.de
// 08.02.2018
let http = require( 'http' );
let https = require( 'https' );
let fs = require( 'fs' );
let path = require( 'path' );
let secureport = process.env.SPORT || 8443;
let port = process.env.PORT || 8080;
let publicdir = "public";
let scriptdir = path.dirname( process.argv[ 1 ] );
/////////////////////////////////////////////////////////////////////////////80
let certdir = "/etc/letsencrypt/live/www.bluepyrami.de";
let credentials = {
key: fs.readFileSync( path.join( certdir, 'privkey.pem' ), "utf8" ),
cert: fs.readFileSync( path.join( certdir, 'fullchain.pem' ) , "utf8" ),
};
/////////////////////////////////////////////////////////////////////////////80
let express = require( 'express' );
let app = express();
app.use((req, res) => {
res.send('Hello there !');
});
/////////////////////////////////////////////////////////////////////////////80
https.createServer( credentials, app ).listen( secureport, function() {
console.log( '%s Node HTTPS server started on port %d ...', Date( Date.now() ), secureport );
} );
/////////////////////////////////////////////////////////////////////////////80
// Redirect from http port 8080 to https
http.createServer( app ).listen( port, function() {
console.log( '%s Node HTTP redirect started on port %d ...', Date( Date.now() ), port );
} );