node.js - NodeJS 子域 w/vhost 和 greenlock-express

标签 node.js express https vhosts greenlock

我是 Node 新手,我想要我的网站,dacio.app ,使用 vhost 为我的大学项目处理子域.

但是,由于 .app 域的要求,我需要确保它的安全,因此我使用 greenlock-express使其自动化。

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

我尝试过使用vhost examplerepo ,但它看起来不像 server-static支持express应用程序。

<小时/>

关于如何让它发挥作用有什么建议吗?我不断听说反向代理,但我不确定它是否值得付出努力,因为我什至不知道它是否有效 - 它有帮助吗?

服务器.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
        }
    }
});

关于node.js - NodeJS 子域 w/vhost 和 greenlock-express,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52241308/

相关文章:

node.js - Nodejs 仍然路由到 mongodb 中已删除的条目

javascript - Next.js:FetchError: invalid json response body Unexpected token < in JSON at position 0

node.js - ExpressJS | app.get() 放置在 app.use() 定义下方时似乎不起作用

javascript - 无法访问 req.user 的属性

javascript - Socket.IO 无法通过 https 连接

node.js - NodeJS + MongoDB : Getting data from collection with findOne ()

javascript - 基本问题 React 与 Express 动态表

mysql - 使用 Node 和 MySQL,如何从表 A 中为特定用户 ID 选择行(表 B)

ssl - 如何将非通配符证书用于 Bluemix?

tomcat - tomcat 的 SSL 设置问题,证书类型为 PrivateKeyEntry