# How to Serve a Blog at /blog With Nginx

> Serve your free Rankwise blog at yourdomain.com/blog from your own Nginx server with two location blocks. Your site and its other routes stay as they are.

Canonical page: [https://tryrankwise.com/resources/guides/add-blog-nginx](https://tryrankwise.com/resources/guides/add-blog-nginx). Updated 2026-10-30. Published by Rankwise (tryrankwise.com).

If your site runs behind **Nginx**, you can serve a blog at yourdomain.com/blog with two `location` blocks. Nginx forwards every /blog request to your Rankwise blog as a reverse proxy. Readers and search engines see your address, and the rest of your site does not change.

This guide covers:

- [What you need](#what-you-need)
- [Step 1: Create the blog in Rankwise](#step-1-create-the-blog-in-rankwise)
- [Step 2: Add the location blocks](#step-2-add-the-location-blocks)
- [Step 3: Test and reload Nginx](#step-3-test-and-reload-nginx)
- [Step 4: Check the blog](#step-4-check-the-blog)
- [Troubleshooting](#troubleshooting)

You need shell access to the server and permission to reload Nginx.

## What you need

- **A Rankwise account.** The [free blog](/free-blog) is enough. It covers 10,000 visits a month.
- **Nginx in front of your site**, with HTTPS already set up for yourdomain.com.
- **Outbound HTTPS** from the server to rankwiseblog.com.
- **A free path.** Your site must not already use /blog. This guide uses /blog.

## Step 1: Create the blog in Rankwise

1. Sign up for Rankwise. On the free blog page, choose **Put it on my own domain at /blog instead**.
2. Open the setup for the blog. Choose **On my own site**.
3. Choose **A path, like /blog**.
4. Enter the blog name, one line about the blog, your website (for example https://yourdomain.com) and the path, for example /blog.
5. Click **Create my blog**.
6. Rankwise shows three snippets. Pick **Nginx** and copy it.

The snippet holds your blog's token. Rankwise shows the token only once, so copy the whole snippet before you leave the page.

This guide covers a blog at a path. To put the blog on a subdomain like blog.yourdomain.com, choose **A subdomain, like blog.yourdomain.com** instead. The snippet then forwards every path on that host, so copy it from the app rather than from this page.

## Step 2: Add the location blocks

Open the Nginx config file for your site and find the `server { }` block that serves yourdomain.com over HTTPS. Paste the snippet inside it. The snippet looks like this, with your own blog id and token:

```nginx
# Inside your server { } block.
location = /blog {
  return 301 /blog/;
}
location /blog/ {
  proxy_pass https://rankwiseblog.com/hosted/YOUR-BLOG-ID/;
  proxy_set_header Host rankwiseblog.com;
  proxy_set_header x-rankwise-blog-token "YOUR-TOKEN";
  proxy_set_header x-rankwise-forwarded-host $host;
  proxy_set_header x-rankwise-visitor-ip $remote_addr;
  proxy_ssl_server_name on;
}
```

Here is what each line does:

- **`location = /blog`** sends a visitor at /blog to /blog/ with a permanent redirect, so the blog has one address.
- **`proxy_pass`** forwards every path under /blog/ to your Rankwise blog. The trailing slash on both sides maps /blog/my-post to the post on Rankwise.
- **`Host rankwiseblog.com`** lets our server accept the request.
- **`x-rankwise-blog-token`** tells Rankwise that the request comes from your server.
- **`x-rankwise-forwarded-host $host`** tells Rankwise which domain serves the blog. Nginx fills `$host` with the hostname the visitor asked for.
- **`x-rankwise-visitor-ip $remote_addr`** passes the visitor's IP address, so Rankwise can limit spam sign-ups to your newsletter form.
- **`proxy_ssl_server_name on`** sends the hostname in the TLS handshake, which our HTTPS certificate needs.

## Step 3: Test and reload Nginx

Test the config before you reload, so a typo never takes your site down:

```bash
sudo nginx -t
sudo systemctl reload nginx
```

If `nginx -t` reports an error, fix the line it names and test again. Use the reload command your system uses, if it does not run systemd.

## Step 4: Check the blog

1. Open yourdomain.com/blog. Nginx redirects you to yourdomain.com/blog/ and shows your blog's index page.
2. Back in Rankwise, click **Check my blog**. When Rankwise finds the blog on your page, it shows as connected.
3. Open yourdomain.com/blog/llms.txt and yourdomain.com/blog/sitemap.xml. Both list your posts once you publish one.

To check that search engines may index the blog, run:

```bash
curl -sI https://yourdomain.com/blog/
```

The answer must not contain `x-robots-tag: noindex`. Rankwise sends that header when the token or the host does not match, so the copy on our server never competes with yours.

## Troubleshooting

**Nginx returns 502 Bad Gateway.** The server cannot reach rankwiseblog.com over HTTPS. Check the server's outbound firewall and DNS, and confirm that `proxy_ssl_server_name on;` is in the block.

**The page loads, but the header says noindex.** The token or the host does not match. Check that **Your website** in the Rankwise setup is your domain. Copy the snippet again from Rankwise and reload Nginx. If a CDN or load balancer sits in front of Nginx, make sure it passes the visitor's hostname through, because `$host` must be your domain. Behind a CDN, `$remote_addr` is the CDN's address, so the sign-up limit counts the CDN. Nginx's `real_ip` module can restore the visitor's address.

**My site already has a `location /` block that catches everything.** Nginx picks the longest matching prefix, so `location /blog/` wins over `location /`. A regex location, such as one for `.php` files, can still catch a blog path, so check those too. Put the blog blocks in the same `server` block as your site.

**Check my blog fails.** Confirm that yourdomain.com/blog/ shows the blog, wait a minute, and try again.

Once the blog is live, every post you publish appears at yourdomain.com/blog with its sitemap entry, RSS item, llms.txt line and Markdown copy.
