roster-server 1.4.2 → 1.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/demo/roster/server.js +1 -1
- package/demo/www/example.com/index.js +1 -1
- package/demo/www/express.example.com/index.js +1 -1
- package/demo/www/sio.example.com/index.js +2 -2
- package/demo/www/subdomain.example.com/index.js +1 -1
- package/index.js +15 -7
- package/package.json +6 -1
package/README.md
CHANGED
|
@@ -26,6 +26,7 @@ Your project should look something like this:
|
|
|
26
26
|
|
|
27
27
|
```
|
|
28
28
|
/srv/
|
|
29
|
+
├── greenlock.d/
|
|
29
30
|
├── roster/server.js
|
|
30
31
|
└── www/
|
|
31
32
|
├── example.com/
|
|
@@ -42,9 +43,8 @@ const Roster = require('roster-server');
|
|
|
42
43
|
|
|
43
44
|
const options = {
|
|
44
45
|
maintainerEmail: 'admin@example.com',
|
|
45
|
-
|
|
46
|
-
wwwPath: '/srv/www'
|
|
47
|
-
staging: false // Set to true for Let's Encrypt staging environment
|
|
46
|
+
greenlockStorePath: '/srv/greenlock.d', // Path to your Greenlock configuration directory
|
|
47
|
+
wwwPath: '/srv/www' // Path to your 'www' directory (default: '../www')
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
const server = new Roster(options);
|
|
@@ -61,7 +61,7 @@ I'll help analyze the example files shown. You have 3 different implementations
|
|
|
61
61
|
|
|
62
62
|
1. **Basic HTTP Handler**:
|
|
63
63
|
```javascript:demo/www/example.com/index.js
|
|
64
|
-
module.exports = (
|
|
64
|
+
module.exports = (httpsServer) => {
|
|
65
65
|
return (req, res) => {
|
|
66
66
|
res.writeHead(200, { 'Content-Type': 'text/plain; charset=utf-8' });
|
|
67
67
|
res.end('"Loco de pensar, queriendo entrar en razón, y el corazón tiene razones que la propia razón nunca entenderá."');
|
|
@@ -73,7 +73,7 @@ module.exports = (server) => {
|
|
|
73
73
|
```javascript:demo/www/express.example.com/index.js
|
|
74
74
|
const express = require('express');
|
|
75
75
|
|
|
76
|
-
module.exports = (
|
|
76
|
+
module.exports = (httpsServer) => {
|
|
77
77
|
const app = express();
|
|
78
78
|
app.get('/', (req, res) => {
|
|
79
79
|
res.setHeader('Content-Type', 'text/plain; charset=utf-8');
|
|
@@ -88,8 +88,8 @@ module.exports = (server) => {
|
|
|
88
88
|
```javascript:demo/www/sio.example.com/index.js
|
|
89
89
|
const { Server } = require('socket.io');
|
|
90
90
|
|
|
91
|
-
module.exports = (
|
|
92
|
-
const io = new Server(
|
|
91
|
+
module.exports = (httpsServer) => {
|
|
92
|
+
const io = new Server(httpsServer);
|
|
93
93
|
|
|
94
94
|
io.on('connection', (socket) => {
|
|
95
95
|
console.log('A user connected');
|
|
@@ -140,7 +140,7 @@ When creating a new `RosterServer` instance, you can pass the following options:
|
|
|
140
140
|
|
|
141
141
|
- `maintainerEmail` (string): Your email for Let's Encrypt notifications.
|
|
142
142
|
- `wwwPath` (string): Path to your `www` directory containing your sites.
|
|
143
|
-
- `
|
|
143
|
+
- `greenlockStorePath` (string): Directory for Greenlock configuration.
|
|
144
144
|
- `staging` (boolean): Set to `true` to use Let's Encrypt's staging environment (for testing).
|
|
145
145
|
|
|
146
146
|
## 🧂 A Touch of Magic
|
package/demo/roster/server.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
module.exports = (
|
|
1
|
+
module.exports = (httpsServer) => {
|
|
2
2
|
return (req, res) => {
|
|
3
3
|
res.writeHead(200, { 'Content-Type': 'text/plain; charset=utf-8' });
|
|
4
4
|
res.end('"Loco de pensar, queriendo entrar en razón, y el corazón tiene razones que la propia razón nunca entenderá."');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
module.exports = (
|
|
1
|
+
module.exports = (httpsServer) => {
|
|
2
2
|
return (req, res) => {
|
|
3
3
|
res.writeHead(200, { 'Content-Type': 'text/plain; charset=utf-8' });
|
|
4
4
|
res.end('"Loco de pensar, queriendo entrar en razón, y el corazón tiene razones que la propia razón nunca entenderá."');
|
package/index.js
CHANGED
|
@@ -5,11 +5,19 @@ const Greenlock = require('greenlock-express');
|
|
|
5
5
|
class Roster {
|
|
6
6
|
constructor(options = {}) {
|
|
7
7
|
this.maintainerEmail = options.maintainerEmail || 'admin@example.com';
|
|
8
|
-
|
|
9
|
-
this.
|
|
8
|
+
const basePath = options.basePath || path.join(__dirname, '..', '..', '..');
|
|
9
|
+
this.wwwPath = options.wwwPath || path.join(basePath, 'www');
|
|
10
|
+
this.greenlockStorePath = options.greenlockStorePath || path.join(basePath, 'greenlock.d');
|
|
10
11
|
this.staging = options.staging || false;
|
|
12
|
+
this.cluster = options.cluster || false;
|
|
11
13
|
this.domains = [];
|
|
12
14
|
this.sites = {};
|
|
15
|
+
|
|
16
|
+
const port = options.port || 443;
|
|
17
|
+
if (port === 80) {
|
|
18
|
+
throw new Error('Port 80 is reserved for ACME challenge. Please use a different port.');
|
|
19
|
+
}
|
|
20
|
+
this.port = port;
|
|
13
21
|
}
|
|
14
22
|
|
|
15
23
|
loadSites() {
|
|
@@ -47,7 +55,7 @@ class Roster {
|
|
|
47
55
|
}
|
|
48
56
|
|
|
49
57
|
generateConfigJson() {
|
|
50
|
-
const configDir = this.
|
|
58
|
+
const configDir = this.greenlockStorePath;
|
|
51
59
|
const configPath = path.join(configDir, 'config.json');
|
|
52
60
|
|
|
53
61
|
if (!fs.existsSync(configDir)) {
|
|
@@ -95,7 +103,7 @@ class Roster {
|
|
|
95
103
|
defaults: {
|
|
96
104
|
store: {
|
|
97
105
|
module: "greenlock-store-fs",
|
|
98
|
-
basePath: this.
|
|
106
|
+
basePath: this.greenlockStorePath
|
|
99
107
|
},
|
|
100
108
|
challenges: {
|
|
101
109
|
"http-01": {
|
|
@@ -179,9 +187,9 @@ class Roster {
|
|
|
179
187
|
|
|
180
188
|
const greenlock = Greenlock.init({
|
|
181
189
|
packageRoot: __dirname,
|
|
182
|
-
configDir: this.
|
|
190
|
+
configDir: this.greenlockStorePath,
|
|
183
191
|
maintainerEmail: this.maintainerEmail,
|
|
184
|
-
cluster:
|
|
192
|
+
cluster: this.cluster,
|
|
185
193
|
staging: this.staging
|
|
186
194
|
});
|
|
187
195
|
|
|
@@ -192,7 +200,7 @@ class Roster {
|
|
|
192
200
|
const { httpsServer, httpServer } = this.initServers(glx);
|
|
193
201
|
|
|
194
202
|
// Primero iniciar el servidor HTTPS
|
|
195
|
-
httpsServer.listen(
|
|
203
|
+
httpsServer.listen(this.port, '0.0.0.0', () => {
|
|
196
204
|
console.log('ℹ️ HTTPS server listening on port 443');
|
|
197
205
|
|
|
198
206
|
// Después iniciar el servidor HTTP
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "roster-server",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.6",
|
|
4
4
|
"description": "👾 RosterServer - A domain host router to host multiple HTTPS.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -19,6 +19,11 @@
|
|
|
19
19
|
"hosting",
|
|
20
20
|
"ssl",
|
|
21
21
|
"host",
|
|
22
|
+
"vhost",
|
|
23
|
+
"virtual-host",
|
|
24
|
+
"socket.io",
|
|
25
|
+
"websocket",
|
|
26
|
+
"express",
|
|
22
27
|
"greenlock-express",
|
|
23
28
|
"clasen"
|
|
24
29
|
],
|