Я пытаюсь запустить Ghost в подкаталоге моего основного проекта Node.js. В настоящее время он размещен на лазурных веб-сайтах.
Что-то вроде: http://randomurlforpost.azurewebsites.net/blog
Я выполнил инструкции здесь: https://github.com/TryGhost/Ghost/wiki/Using-Ghost-as-an-NPM-module
С новым добавлением использования Ghost в качестве модуля npm мне все еще нужен Nginx или Apache ?. На данный момент мой основной сайт работает на localhost: 3000, а экземпляр Ghost - на localhost: 2368.
Я пробовал вносить всевозможные модификации в ту часть кода, которая указана в инструкциях, но мне это не удалось.
//app.js, is there a specific place to put this?
var ghost = require('ghost');
ghost().then(function (ghostServer) {
ghostServer.start();
});
//config.js
development: {
url: 'http://localhost:3000/blog',
database: {
client: 'sqlite3',
connection: {
filename: path.join(__dirname, '/content/data/ghostdev.db')
},
debug: false
},
server: {
host: '127.0.0.1',
port: '2368'
},
paths: {
contentPath: path.join(__dirname, '/content/'),
}
},
//index.js
ghost().then(function (ghostServer) {
parentApp.use(ghostServer.config.paths.subdir,ghostServer.rootApp);
// Let ghost handle starting our server instance.
ghostServer.start(parentApp);
}).catch(function (err) {
errors.logErrorAndExit(err, err.context, err.help);
});
РЕДАКТИРОВАТЬ: мне удалось перенаправить трафик с помощью http-proxy, однако он направляет его на localhost: 2368 / blog (которого не существует) любые идеи о том, как предотвратить это?
var httpProxy = require('http-proxy');
var blogProxy = httpProxy.createProxyServer();
var ghost = require('ghost');
var path = require('path');
// Route /blog* to Ghost
router.get("/blog*", function(req, res, next){
blogProxy.ws(req, res, { target: 'http://localhost:2368' });
});