Run Ghost Blog as a subfolder of a website running on a node http server

First, forgive my lack of understanding of the Joyent smartmachine instance. For this scenario, I am running a free dev class smartmachine module for NodeJS.

I am running a website in [path]/server/public/ on the file system via http-server , and I want to run Ghost on the [path]/server/public/blog/ at the same time, as on port 80.

Is it possible? How can i do this?

+8
joyent ghost-blog smartos
source share
3 answers

Setting up thin wrappers using express can be a good solution (as Paul recommends), but it can be a mess if you end up with a large application with a lot of "differential services".

Instead, force proxies (like NGINX) on top of all my services.

With this solution, if the service fails, the others do not because they are untied.

You can listen on port 80 and the proxy server inside each service: port.

Something like:

 0.0.0.0:80 ---> Proxy └──path: / ─── localhost:3000 (Main Web) └──path: /blog ─── localhost:4000 (Ghost) ... 
+7
source

If your other site is an express based site, the easiest way is to include your ghost application in the same source tree (possibly in a subfolder). Express applications can be installed as middleware for other express applications, so you can add a route to your main site, for example:

 var ghost = require('./path/to/ghost'); app.use('/blog', ghost); 
+3
source

Assuming you followed β€œInstall from zip (faster and better for bloggers)” from https://github.com/tryghost/Ghost , and you are serving static content from / public / with an http server.

My solution is to use the Ghost Express server to serve your content:

Download Ghost.zip and unzip to [path]/server/

Open the Ghost config.js file and change the URL in development http: // localhost: 2368 to <a2>

Now open the index.js file in the same directory and add the following:

parentApp.use(express.static(__dirname + '/public'));

after: parentApp = express();

where '/ public' is the directory containing your static content.

Now, if you go to http: // localhost: 2368 , you will find your site and your blog will be at http: // localhost: 2368 / blog /

To proceed to production, you need to make the appropriate changes and start with NODE_ENV=production npm start . To go to port 80, you only need to change the port inside config.js, and this will serve both your website and the blog on 80. This will obviously give you an insufficient resolution problem and there are a ton of tutorials that show how configure Node.js on port 80, so follow this.

+2
source

All Articles