How to install Ghost and Gitlab in different subdomains?

Posted March 10, 2015 5.1k views
NginxUbuntuApacheGitDigitalOceanGhostDigitalOcean 1-Click Apps Marketplace


I would like to setup a VPS with multiple applications. E.g. Gitlab and Ghost. Both of them in diferrent subdomains ( & Also I would like to have an html page at

I don’t care about apache or nginx. On Ubuntu 14.04.

What would be the easiest way to do this?



These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

This can be accomplished with Nginx by creating separate server block for each app/site. As a quick example, hosting a static site on www and a Ghost instance on blog, your Nginx config would look something like this:

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;


    client_max_body_size 10G;

    location / {
        proxy_pass http://localhost:2368;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_buffering off;

server {
    listen 80;
    listen [::]:80 ipv6only=on;

    root /var/www/html/;
    index index.html index.htm;


    location / {
        try_files $uri $uri/ =404;

This would serve static html from the directory /var/www/html/ at It would also proxy a Ghost instance running on port 2368 to The server_name directive is important so that Nginx knows where to direct the requests. This also assumes that you have DNS set up with A records for both subdomains pointing to this IP address.

This tutorial should help point you in the right direction:

by Justin Ellingwood
Nginx is an incredibly powerful web server and reverse proxy. In this guide, we'll discuss how to set up server blocks on Ubuntu 14.04 in order to server multiple domains from a single server.