How to run discourse on subdirectory of external domain?

We are moving away from our wordpress website to a cloud hosted e-commerce platform, which will use our bare domain due to our high SEO ranking.

I want to move our posts to discourse, but run it under the same domain is that possible?

To be clear, will be running in a external server I can’t control or access so I believe I can’t use nginx tricks or something. I only have access to the server that will be running discourse.

My goal is to move posts like this to discourse but keep same path or at best domain/blog/same-url while my bare domain is pointed and hosted in a Wix-like platform.

It might be possible to have cloudflare in front of both sites with a rule to route traffic to discourse for the subfolder. I am not aware of anyone doing that. You’ll probably need to hire someone or figure out out on your own. Just follow the topic here about subfolder installs and whatever cloudflare has about the same.

I thought that the belief that a subfolder was better for seo had gone away. My recommendation would be to just use a subdomain, but if you have a budget contact me or post in marketplace.


You could technically achieve the subfolder part at Cloudflare using an Enterprise page rule or maybe via workers but I’m pretty skeptical that we could provide any assistance with either.

Cloudflare is hard to support in any form beyond DNS.

And yes, Google themselves have debunked the whole SEO snake oil around cramming everything under a single domain.


Better safe than sorry with SEO. I don’t see how a blog.domain would boost my domain seo, so there is no point in having a blog domain at all.

I’ve been thinking in following this guide. Which assetsPathnames: ["/public/", "/assets/"] I should use?

Subfolder installs are much more complicated and very fragile.

The point is that there’s zero benefit running under the same FQDN and significantly more risk and cost.


That’s what you believe. But there is no evidence that a subdomain helps boost the bare domain at all.

And even cloudflare recommends running everything in the same domain.

Then why, pray tell, is their discourse community on a subdomain?


Because anything with cloudflare in the domain will rank well. And their forum is enormous

If that’s what you believe, move along. There is nothing for you here. Go elsewhere, go somewhere that people believe the same things you do.


I could link much more links, with data behind them if I wasn’t limited to 2 links. And except for Cloudflare, which is massive and don’t need to focus on SEO all websites on the first page for this search use subdirectories

It won’t be hard to find other places where people believe the same thing since this seems to be consensus on the SEO community.

But sure, if you have ANY evidence that a subdomain helps rank the root domain please enlighten the internet :slight_smile:

Direct from Matt Cutts. Your SEO “experts” are selling you snake oil.

Through the years some of the worst, least competent people I’ve ever seen on a team are the “SEO experts”. They are uniformly a disgrace and an embarrassment to the industry.


True! Tons better to do something that most everyone agrees won’t help web rankings but will likely result in your site being down unexpectedly with no clear means to fix it.


Anyone have tried to do this with cloudflare?

As we’ve already explained in your other topic, what you’re asking to do can’t be supported here.

You will either need an Enterprise plan with Cloudflare, or to create custom workers. Either way you should be talking to Cloudflare.


As stated, the answer that I gave earlier, is all you’ll get here.

What I didn’t make clear enough is that it’s a fool’s errand.

For a frame of reference, I’d charge you on the order of $1000 and provide no promise that it would work for for more than a week after I set it up. (or I might charge $500 with no promise that I could figure it out at all.

And you’d need the cloudflare enterprise plan.

If you’re interested, post in marketplace and include a budget and that you are willing to pay for cloudflare enterprise and understand that it is likely impossible.


I think I’m 80% done in implementing this. I installed discourse on a subdomain as “normal” install.

Then I created a cloudflare worker proxying /blog to my subdomain. It works but chrome refuses to load some stuff because of CSP policy.

Any ideas to go around this anyone? I’ll share my workers code when it’s 100%.

You can go to UltraLuz Blog - Lampadas led to check what is happening.

My idea is that after I fix this, I’ll just use robots.txt to block google from indexing my subdomain, so it only sees and indexes /blog while I can still access the subdomain just fine if needed


This is never going to work really well with a “normal” install, you really should follow the subfolder install procedure. It will fix your CSP issues and many more. Apart from that, I think you’re almost there.


What I should set DISCOURSE_HOSTNAME when using DISCOURSE_RELATIVE_URL_ROOT ? The relative root will be blog for me right?

How does this change stuff related to SSL? This is my env section of yml

  LANG: en_US.UTF-8



  SSL_POLICY: Mozilla-Modern  

The letsencrypt and virtual host stuff is for my nginx docker (jwilder/nginx-proxy) that handles the proxying and ssl creation for me based on that variables…

Also had this but I think it will be fully replaced by the code there?

  - replace:
      filename: /etc/nginx/conf.d/discourse.conf
      from: "types {"
      to: |
        real_ip_header X-Forwarded-For;
        real_ip_recursive on;
        types {
1 Like

Yes, /blog including the slash.

No, just

I guess you should leave the LetsEncrypt part as it is.


It didn’t work this way. I guess it’s because the worker needs a domain to fetch stuff, and since the root domain is on a different IP.

I’m basically telling the worker "when someone goes to /blog fetch this from rootdomain/blog" this of course just displays my current wordpress 404 error page.

I think because of the whole same domain, multiple IPs/servers things a subdomain is needed to load the discourse assets. But it’s late now and I need to sleep.

But I think the easiest way to achieve this will be to just fix the CSP errors with usual subdomain install.

1 Like