【发布时间】:2015-01-23 04:16:29
【问题描述】:
我正在尝试在我的主要 Node.js 项目的子目录中运行 Ghost。它目前托管在 azure 网站中。
就像是:
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' });
});
【问题讨论】:
标签: node.js azure nginx ghost-blog