带有 vhost 和 greenlock-express 的 NodeJS 子域

NodeJS Subdomain w/ vhost and greenlock-express

我是 Node 新手,我想要我的网站,dacio.app, working with subdomains for my college projects using vhost

但是,由于对 .app 域的要求,我需要对其进行保护,因此我使用 greenlock-express 来实现自动化。

Don't be frontin', yo! TLS SNI 'giphy.dacio.app' does not match 'Host: potatoes.dacio.app'

我试过使用 vhost example in the repo, but it doesn't look like server-static supports express 应用程序。


关于如何让它工作的任何提示?我一直听说反向代理,但我不确定它是否值得付出努力,因为我什至不知道它是否有效 - 它有帮助吗?

server.js

#!/usr/bin/env node
'use strict';

// DEPENDENCIES
const express = require('express');
const vhost   = require('vhost');
const path    = require('path');
const glx     = require('greenlock-express');

// MIDDLEWARE
const app = express();
const giphyApp = require('../giphy-search');
const potatoesApp = require('../rotten-potatoes');
const portfolioApp = require('../dacio.app');

// ROUTES
app.use(vhost('giphy.dacio.app', giphyApp));
app.use(vhost('potatoes.dacio.app', potatoesApp));
app.use(portfolioApp);

// GREENLOCK for HTTPS
glx.create({
    version: 'draft-11',
    server: 'https://acme-v02.api.letsencrypt.org/directory',
    email: 'dacioromero@gmail.com',
    agreeTos: true,
    approveDomains: [ 'dacio.app', 'giphy.dacio.app', 'potatoes.dacio.app' ],
    configDir: '~/.config/acme/',
    app: app,
    communityMember: false
}).listen(80, 443);

我已经改用 redbird,这似乎完成了我希望做的一切。

const path = require('path')

const proxy = require('redbird')({
    port: 80,
    letsencrypt: {
        path: path.join(__dirname, '/certs'),
        port: 9999
    },
    ssl: {
        http2: true,
        port: 443
    }
});

proxy.register('dacio.app', 'http://localhost:8080', {
    ssl: {
        letsencrypt: {
            email: 'dacioromero@gmail.com',
            production: true,
        }
    }
});

proxy.register('giphy.dacio.app', 'http://localhost:8081', {
    ssl: {
        letsencrypt: {
            email: 'dacioromero@gmail.com',
            production: true
        }
    }
})

proxy.register('potatoes.dacio.app', 'http://localhost:8082', {
    ssl: {
        letsencrypt: {
            email: 'dacioromero@gmail.com',
            production: true
        }
    }
});