# Install Ghost alongside other nodejs web app

**URL:** <https://forum.ghost.org/t/install-ghost-alongside-other-nodejs-web-app/26946>\
**Category:** Installation\
**Created:** [November 23, 2021, 7:06pm UTC](https://forum.ghost.org/t/install-ghost-alongside-other-nodejs-web-app/26946 "2021-11-23T19:06:43Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![lekiet1214](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/lekiet1214/32/15746_2.png) [@lekiet1214](https://forum.ghost.org/u/lekiet1214)\
**Post date:** [November 23, 2021, 7:06pm UTC](https://forum.ghost.org/t/install-ghost-alongside-other-nodejs-web-app/26946/1 "2021-11-23T19:06:43Z")

</div>

Hi,  
I am trying to install Ghost on my server, which is already running an express app with nginx. I have been trying to find some ways through but there have not been any effective solutions yet.  
I’d really appreciate any help or just hint is also nice.

Addition: I’m working on an Oracle VM, ubuntu 20.04 LTS. And yes, the express app use port 80.

Clarification: the express app is serving as [www.nhonho.tech](https://www.nhonho.tech) , I want to have Ghost up at [blog.nhonho.tech](https://blog.nhonho.tech) or www.nhonho.tech/blog . I also use Cloudflare as dns for my domain.

Update: I have installed Ghost on [blog.nhonho.tech](https://blog.nhonho.tech), but now Ghost also goes to [nhonho.tech.](https://nhonho.tech.) How can I advoid that?  
Update 2: If I access the web page by IP, it shows the express app, which is supposed to be at [nhonho.tech](https://nhonho.tech)

My nginx configuration:

```auto
server
{
 listen 443 ssl http2;
 listen [::]:443 ssl http2;

 server_name nhonho.tech www.nhonho.tech;
 root /usr/share/das-express/bin;
 ssl_certificate /etc/ssl/certs/cloudflare_nhonho.tech.pem;
 ssl_certificate_key /usr/share/das-express/bin/key.key;
 ssl_client_certificate /usr/share/das-express/bin/li.pem;
 ssl_verify_client on;

 location / {
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
     proxy_set_header X-Forwarded-Proto $scheme;
     proxy_set_header X-Real-IP $remote_addr;
     proxy_set_header Host $http_host;
     proxy_pass http://127.0.0.1:8080;

 }

 location ~ /.well-known {
     allow all;
 }

 client_max_body_size 50m;
}

server
{
  listen 443 ssl http2;
    listen [::]:443 ssl http2;

    server_name blog.nhonho.tech;
    root /var/www/sitename/system/nginx-root;

    ssl_certificate /etc/letsencrypt/blog.nhonho.tech/fullchain.cer;
    ssl_certificate_key /etc/letsencrypt/blog.nhonho.tech/blog.nhonho.tech.key;
    include /etc/nginx/snippets/ssl-params.conf;

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $http_host;
        proxy_pass http://127.0.0.1:2368;

    }
}

```

---

<div class="post-metadata">

**Author:** ![inoryum](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/inoryum/32/11866_2.png) [@inoryum](https://forum.ghost.org/u/inoryum)\
**Post date:** [November 23, 2021, 11:38pm UTC](https://forum.ghost.org/t/install-ghost-alongside-other-nodejs-web-app/26946/2 "2021-11-23T23:38:02Z")

</div>

You can install ghost normally & it wont affect your current node web-apps. Ghost uses port `2368` Just make sure the port is not being used with another process.

---

<div class="post-metadata">

**Author:** ![lekiet1214](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/lekiet1214/32/15746_2.png) [@lekiet1214](https://forum.ghost.org/u/lekiet1214)\
**Post date:** [November 24, 2021, 1:44am UTC](https://forum.ghost.org/t/install-ghost-alongside-other-nodejs-web-app/26946/4 "2021-11-24T01:44:09Z")

</div>

I installed Ghost at blog.nhonho.tech, it runs fine, the problem now is Ghost also shows at nhonho.tech.

---

<div class="post-metadata">

**Author:** ![inoryum](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/inoryum/32/11866_2.png) [@inoryum](https://forum.ghost.org/u/inoryum)\
**Post date:** [November 24, 2021, 10:15am UTC](https://forum.ghost.org/t/install-ghost-alongside-other-nodejs-web-app/26946/5 "2021-11-24T10:15:45Z")

</div>

This might be a webserver config issue. Can you please share your webserver config here or in DM?

---

<div class="post-metadata">

**Author:** ![lekiet1214](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/lekiet1214/32/15746_2.png) [@lekiet1214](https://forum.ghost.org/u/lekiet1214)\
**Post date:** [November 24, 2021, 11:52am UTC](https://forum.ghost.org/t/install-ghost-alongside-other-nodejs-web-app/26946/6 "2021-11-24T11:52:22Z")

</div>

I’ve updated my nginx configuration on post. Can you spot any problems?

---

<div class="post-metadata">

**Author:** ![inoryum](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/inoryum/32/11866_2.png) [@inoryum](https://forum.ghost.org/u/inoryum)\
**Post date:** [November 24, 2021, 1:47pm UTC](https://forum.ghost.org/t/install-ghost-alongside-other-nodejs-web-app/26946/7 "2021-11-24T13:47:09Z")

</div>

make sure on ghost `config.production.json` file the URL is defined as [https://blog.nhonho.tech](https://blog.nhonho.tech)

Nginx server block seems fine but what I am suspecting both are in the same config file. Did you create a separate config file for your ghost instance ? If not then follow below:

create a nginx server block for blog

```auto
sudo nano /etc/nginx/sites-available/blog.nhonho.tech

```

cut the blog config to the new file `/etc/nginx/sites-available/blog.nhonho.tech`

```auto
server {

    listen 80;
    server_name blog.nhonho.tech;
    return 301 https://$host$request_uri;
}
server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    server_name blog.nhonho.tech;
    root /var/www/sitename/system/nginx-root;

    ssl_certificate /etc/letsencrypt/blog.nhonho.tech/fullchain.cer;
    ssl_certificate_key /etc/letsencrypt/blog.nhonho.tech/blog.nhonho.tech.key;
    include /etc/nginx/snippets/ssl-params.conf;

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $http_host;
        proxy_pass http://127.0.0.1:2368;

    }
}

```

Now enable the newly created nginx server block

```auto
sudo ln -s /etc/nginx/sites-available/blog.nhonho.tech /etc/nignx/sites-enabled/

```

Restart Nginx

```auto
sudo systemctl restart nginx

```

After restart it should work

---

<div class="post-metadata">

**Author:** ![lekiet1214](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/lekiet1214/32/15746_2.png) [@lekiet1214](https://forum.ghost.org/u/lekiet1214)\
**Post date:** [November 24, 2021, 8:09pm UTC](https://forum.ghost.org/t/install-ghost-alongside-other-nodejs-web-app/26946/8 "2021-11-24T20:09:50Z")

</div>

I created blog.nhonho.tech.conf and nhonho.tech.conf (the ghost setup create file with `.conf`)

the `nhonho.tech.conf`:

```auto
    listen 80;
    listen [::]:80;

    server_name nhonho.tech www.nhonho.tech;
    root /usr/share/das-express;

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $http_host;
        proxy_pass http://127.0.0.1:8080;
    }

}

```

The `blog.nhonho.tech.conf` :

```auto
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    server_name blog.nhonho.tech;
    root /var/www/sitename/system/nginx-root;

    ssl_certificate /etc/letsencrypt/blog.nhonho.tech/fullchain.cer;
    ssl_certificate_key /etc/letsencrypt/blog.nhonho.tech/blog.nhonho.tech.key;
    include /etc/nginx/snippets/ssl-params.conf;

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $http_host;
        proxy_pass http://127.0.0.1:2368;

    }
}

```

Main site nhonho.tech is now good, except that Ghost site blog.nhonho.tech is now nowhere.  
Also, when I run `nginx -t`, it returned:

```auto
root@localhost:/etc/nginx/sites-enabled# nginx -t
nginx: [warn] conflicting server name "blog.nhonho.tech" on 0.0.0.0:443, ignored
nginx: [warn] conflicting server name "blog.nhonho.tech" on [::]:443, ignored
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

```

---

<div class="post-metadata">

**Author:** ![lekiet1214](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/lekiet1214/32/15746_2.png) [@lekiet1214](https://forum.ghost.org/u/lekiet1214)\
**Post date:** [November 25, 2021, 3:16am UTC](https://forum.ghost.org/t/install-ghost-alongside-other-nodejs-web-app/26946/9 "2021-11-25T03:16:33Z")

</div>

I reinstalled nginx and changed Ghost from `https` to `http`, I’ll let the encrypt to Cloudflare.  
The web seems to run fine now.  
I think the problem is the different protocols used by two app, express use `http` while Ghost use `https`. Now they both use `http` and Cloudflare will take care of the rest.

---

<div class="post-metadata">

**Author:** ![jeff](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/jeff/32/4900_2.png) [@jeff](https://forum.ghost.org/u/jeff)\
**Post date:** [November 27, 2021, 11:07am UTC](https://forum.ghost.org/t/install-ghost-alongside-other-nodejs-web-app/26946/10 "2021-11-27T11:07:17Z")

</div>

It is possible to have multiple HTTPS sites on your web-server - it’s almost all down to your NGINX config. It’s also easy to mix and match HTTP and HTTPS. There is lots of NGINX help available via Google.

From the comments above it looks like you had both old and new config setup at the same time in the `/etc/nginx/sites-enabled` folder - this is why NGINX complained about duplicate servers.

HTTPS is important as it lets your readers verify that they have connected to your actual site, and not to another server pretending to be you. It also protects your Ghost username/password when you login to your Admin pages.

You should be aware that if you connect via an IP to your HTTPS server, NGINX will choose the FIRST server in `/etc/nginx/sites-enabled/`’ that is listening on 443 - so you can manage this using careful naming of the links in this folder - that’s why lots of folks use link-names like `00_default, 10_nhonho.tech, 20_blog-nhonho.tech` etc.

---

<div class="post-metadata">

**Author:** ![tq-bit](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/tq-bit/32/14310_2.png) [@tq-bit](https://forum.ghost.org/u/tq-bit)\
**Post date:** [December 14, 2021, 6:37pm UTC](https://forum.ghost.org/t/install-ghost-alongside-other-nodejs-web-app/26946/11 "2021-12-14T18:37:04Z")

</div>

Hi Lekiet,

you could try and create a new server context in your nginx config that listens on another port, such as 8443. In it, you can use the same location config as above.

Next, you can make your cloudflare domain point to port 8443 instead of the https default of 443. The IP would look something like this:

> If your primary domain [https://www.nhonho.tech](https://www.nhonho.tech) points to `127.0.0.1:443`  
> Your blog’s subdomain [https://blog.nhonho.tech](https://blog.nhonho.tech) should point to `127.0.0.1:8443`

Depending on what domain is targetted, nginx should now proxy the request either to your primary webapp or to the respective Ghost instance.
