Local Video Hosting in Ghost

Local Video Hosting in Ghost

Important

Before you proceed, please fully understand:
When you choose to host videos locally, it will cause certain amount of outbound data transfer. Unless you subscribed a fixed bandwidth, or with enough data transfer allowance --- if your plan is pay-as-you-go for data transfer, large bills of outbound data transfer fee may occur.

1. Background

Ghost does not allow users to upload videos. You can only use third party embedded source, such as YouTube, Vimeo. This is an alternative way to host videos on the same server as Ghost.

2. Config Nginx

In your Ghost Nginx configuration file add the following alongside your Ghost proxy:

location ^~ /videos {
    root /var/www;
}

For example: (path may vary)

nano /etc/nginx/conf.d/ghost.conf
...
...
   location / {
        proxy_pass http://127.0.0.1:3000;
        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;
    }

# Add below three lines 
    location ^~ /videos {
        root /var/www;
    }

3. Add videos

mkdir /var/www/videos

You can use FTP application such as FileZilla, to upload videos to this directory.

Restart Nginx

systemctl restart nginx

4. Insert videos in Ghost

You can insert video source via HTML or Markdown

<video controls width="500">
    <source src="https://your.ghost.com/videos/yourfile.mp4"
            type="video/mp4">
</video>

All HTML controls apply.


Copyright statement: Unless otherwise stated, all articles on this blog adopt the CC BY-NC-SA 4.0 license agreement. For non-commercial reprints and citations, please indicate the author: Henry, and original article URL. For commercial reprints, please contact the author for authorization.