Host blog on subdirectory path
This guide outlines the required steps and configurations to serve a Ghost blog hosted on typetale.app under a subdirectory (e.g., yourdomain.com/blog).
This guide outlines the required steps and configurations to serve a Ghost blog hosted on typetale.app under a subdirectory (e.g., yourdomain.com/blog), while your main website continues operating independently under yourdomain.com. The configuration demonstrates an Nginx reverse proxy, but the principles apply to other reverse proxies.
1. Provision the Ghost Site
Provision a Ghost blog on typetale.app. For the purposes of these instructions, assume typetale.app provisions the blog at demo.ontypetale.com
2. Configure the path in Ghost Admin console
Login to your ghost admin dashboard (e.g. demo.ontypetale.com/ghost). Navigate to Console page (see the sidebar). Select domains tab, scroll to Sub-directory Configuration section and add your sub-directory url path. Save the changes and next we need to setup the reverse proxy.
3. Configure Reverse Proxy on yourdomain.com
On yourdomain.com’s web server, configure a reverse proxy that forwards all /blog traffic (including subpaths) to demo.ontypetale.com. Here is the recommended Nginx configuration:
server {
server_name yourdomain.com;
# ... (existing site configuration)
location /blog/ {
proxy_pass **https://demo.ontypetale.com**;
proxy_ssl_server_name on;
proxy_set_header Host demo.ontypetale.com;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
}
listen 443 ssl;
ssl_certificate /path/to/your/ssl/certificate.pem;
ssl_certificate_key /path/to/your/ssl/certificate_key.pem;
}
This setup transparently proxies all requests to /blog and subpaths (e.g., /blog/post-title) to demo.ontypetale.com while maintaining correct header information for Ghost to generate absolute URLs and track original clients.
4. Essential Headers
The following headers are required for Ghost's subdirectory routing to work seamlessly:
- X-Forwarded-Proto: should always indicate https (or http, as appropriate)
- X-Forwarded-Host: must be set to yourdomain.com
- X-Real-IP: client's actual IP address
- X-Forwarded-For: client IP, supports chained proxies
- Host: must be set to demo.ontypetale.com
This header setup keeps the Ghost instance aware of the true request origin and path context.
5. Verification and Testing
- Navigate to https://yourdomain.com/blog and verify that blog content loads correctly, including all assets, static files, and deep URLs (e.g., https://yourdomain.com/blog/some-article).
- The Ghost Admin interface will be available at https://yourdomain.com/blog/ghost if the proxy passes through that path as well.
- Check that canonical URLs, RSS feeds, and sitemaps use the subdirectory path.
6. Summary Table
| Application Domain | Proxy Subdirectory | Mandatory Proxy Headers |
|---|---|---|
| yourdomain.com | /blog | X-Forwarded-Proto, X-Forwarded-Host, X-Real-IP, X-Forwarded-For, Host |
This approach enables an organization to present editorial content via Ghost in a cohesive, SEO-friendly format inside their main domain.