我是 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 example在 repo ,但它看起来不像 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/