How can I switch from Ghost to another node application running on a different port?

Keywords: Ghost - AWS - How to - Other
Description:
I have a Ghost application instance running fine. I also have a different node.js app running fine on port 3000. The domain http:myserver.bitnamiapp.com directs to Ghost as expected. I would like to view the other node app in the browser by entering http:myserver.bitnamiapp.com:3000 but this isn’t being allowed by the default config. How do I configure Apache to direct me to the node app on port 3000 while leaving Ghost running ?

Hi @aidan.dunsdon

Thanks for using Bitnami Ghost!

We have a Support Tool that will gather relevant information for us to analyze your configuration and logs. Could you please execute it on the machine where the stack is running by following the steps described in the guide below?

Please note that you need to paste the code ID that is shown at the end.

With that, I will be able to analyse your instance configuration and advice accordingly :grinning_face_with_smiling_eyes:

Best regards,
Jose Antonio Carmona


Was my answer helpful? Click on :heart:

1 Like

Hi Jose

Support ID is 2ac4d52e-9f96-ee8b-9e60-5cdfe5501602

Many Thanks

Aidan

Hi @aidan.dunsdon

Thanks for sharing the code!

There is a guide for this, but it some parts seem to be outdated:
https://docs.bitnami.com/google/apps/ghost/administration/create-custom-application-nodejs/

Here are the steps I have followed in order to create another node application running on the same Ghost.

  1. Back up any important files or configuration before proceeding, so that in the unlikely event of a loss you have a returning point available.

  2. As I don’t have an extra NodeJS application, I’ll be using Express to create a sample one. In order to do that, I first install express and then set up a new application under the folder /opt/bitnami/apps/ (that already exists :slightly_smiling_face:)

$ sudo npm -g install express-generator
$ express --view pug sample
  create : sample/
   create : sample/public/
   create : sample/public/javascripts/
   create : sample/public/images/
   create : sample/public/stylesheets/
   create : sample/public/stylesheets/style.css
   create : sample/routes/
   create : sample/routes/index.js
   create : sample/routes/users.js
   create : sample/views/
   create : sample/views/error.pug
   create : sample/views/index.pug
   create : sample/views/layout.pug
   create : sample/app.js
   create : sample/package.json
   create : sample/bin/
   create : sample/bin/www

   change directory:
     $ cd sample

   install dependencies:
     $ npm install

   run the app:
     $ DEBUG=sample:* npm start

$ sudo chown -R /opt/bitnami/apps/sample && sudo chmod -R u+rw /opt/bitnami/apps/sample
$ cd sample
$ npm install
  1. Create a folder that will hold the VirtualHost configuration for your Apache instance:
$ pwd
/opt/bitnami/apps/sample

$ mkdir conf
  1. Create the following file inside the aforementioned folder:
$ nano sample-http-vhost.conf
 <VirtualHost _default_:3000> #--> Listening at port 3000
    ServerAlias *
    DocumentRoot "/opt/bitnami/apps/sample/public" # --> Replace it with your path
    <Directory "/opt/bitnami/apps/sample/public"> # --> Same here
      Require all granted
    </Directory>
    ProxyPass / http://localhost:3000/ # --> This is where your NodeJS server is at
    ProxyPassReverse / http://localhost:3000/
  </VirtualHost>
  1. Include this file in your /opt/bitnami/apache2/conf/bitnami-apps-vhosts.conf file:
$ cat /opt/bitnami/apache2/conf/bitnami/bitnami-apps-vhosts.conf 
# Bitnami applications installed in a Virtual Host
+ Include "/opt/bitnami/apps/sample/conf/sample-http-vhost.conf"
  1. Daemonize your NodeJS application with forever:
$forever start /opt/bitnami/apps/sample/bin/www
  1. Check your syntax and restart apache:
$ sudo apachectl -t
Syntax OK

$ sudo /opt/bitnami/ctlscript.sh restart apache
  1. Modify the firewall rules in your cloud to allow tcp traffic for port 3000. You can do that by following the guide here:
    https://docs.bitnami.com/aws/faq/administration/use-firewall/

  2. Your application should be accessible now at http://YOUR-DOMAIN:3000 !

image

Could you please try these steps and report back?

Best regards,
Jose Antonio Carmona


Was my answer helpful? Click on :heart:

1 Like

Hi Jose

Worked like a charm. I can now access the node node app on port 3000!

Many thanks indeed for your clear instructions and for going the extra mile to test the suggested solution first.

Thanks again

Aidan

My pleasure @aidan.dunsdon !

I will take the opportunity to mention the doc team to update it :slightly_smiling_face:, thanks for your issue!

We are marking the previous answer as “Solution” and this topic as “Closed”.

If you have any other questions, please do not hesitate to let us know. Feel free to create a new topic referencing to this one if necessary.

Best regards,
Jose Antonio Carmona


Was my answer helpful? Click on :heart:

1 Like

Thanks. We have updated the documentation.