# Use a subfolder (path prefix) to serve Discourse with multiple servers sharing a domain

**URL:** https://meta.discourse.org/t/use-a-subfolder-path-prefix-to-serve-discourse-with-multiple-servers-sharing-a-domain/30514
**Category:** Self-Hosting
**Tags:** subfolder, how-to, advanced-setup, domains
**Created:** [26.Июнь.2015 20:57:34 UTC](https://meta.discourse.org/t/use-a-subfolder-path-prefix-to-serve-discourse-with-multiple-servers-sharing-a-domain/30514 "2015-06-26T20:57:34Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Discourse](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/discourse/32/148734_2.png) [@Discourse](https://meta.discourse.org/u/Discourse)
#### Post date: [26.Июнь.2015 20:57:34 UTC](https://meta.discourse.org/t/use-a-subfolder-path-prefix-to-serve-discourse-with-multiple-servers-sharing-a-domain/30514/1 "2015-06-26T20:57:34Z")

</div>

Let’s say you have a WordPress blog on `http://=DOMAIN=`, and you want to serve your Discourse forums (which run on a different server) from `http://=DOMAIN==PATH=`. How do you do that?

* * *

**Note** : _This won’t work for serving multiple Discourse instances from different folders on the same domain. You need to use different subdomains so that each site can have different cookies._

* * *

You’re going to need to send all traffic for the domain to one place that can route traffic to the correct server. In this how-to, I’ll use [Fastly](https://www.fastly.com/). So, Discourse will be running on one server, and the other parts of your site (like WordPress) will run on one or more other servers.

## Docker container changes

[First, follow the instructions here to serve Discourse from a subfolder](https://meta.discourse.org/t/subfolder-support-with-docker/30507).

## Fastly

Now to setup Fastly to send traffic to the right place based on the path. I’ll assume that Discourse is being served from `=PATH=`.

Create a new service pointing to your main website and follow the instructions for updating your DNS settings.

![](https://global.discourse-cdn.com/meta/original/3X/6/6/661f361b75f1acdb8f69efb76594d07a96ddba16.png)

Go to the service and click “Configure”. Make sure you have selected Version 2 so that you can make changes. Version 1 is the currently active version and can’t be changed.

In the “Hosts” section, add your Discourse server as a second backend.

 ![](https://global.discourse-cdn.com/meta/original/3X/b/3/b3ff903034346f63a02ad0b219ba38a87c4cd0fc.jpg) 

In the Settings tab, add a new entry under Request Settings named “Discourse Pass” with action “Pass”.

 ![](https://global.discourse-cdn.com/meta/original/3X/0/6/060dd5804fc8159e530ec1b5092beed65c68bff1.jpg) 

Finally, for each host edit the conditions to specify where to route traffic.

![](https://global.discourse-cdn.com/meta/original/3X/d/2/d24700f8cc3a00097d056964b032867ad485e405.png)

For your main website, non-Discourse URLs should match.

```plaintext
req.url !~ "^=PATH="

```

 ![](https://global.discourse-cdn.com/meta/original/3X/1/5/15c1096e4d9eb8a1731105a337d8e7f37740051b.jpg) 

For the Discourse host, `=PATH=` URLs should match.

```plaintext
req.url ~ "^=PATH="

```

 ![](https://global.discourse-cdn.com/meta/original/3X/d/e/de42fe4884434dbeae4d82e22a544ba7ac698cde.jpg)

> Last edited by @JammyDodger 2024-05-26T21:37:13Z
> 
> > **Check document**
> >
> > Perform check on document:
