How do I proxy an application through Netlify?

I’m trying to proxy (discourse) through to (netlify).

I’ve set up:

/f/* 200

It works if I reach to certain files e.g., but in theory should produce the forum, which it doesn’t.

Have I done this correctly?

Hi, @chrism2671. This site has Cloudflare proxying in front of it which limits our support team’s ability to troubleshoot this.

The site being proxied to also has Cloudflare in front of it. This could be some unexpected issue caused by using a proxy to a proxy which then proxies again back to the original proxy.

All I can say on the Netlify site is that the proxy rule is working at our service. Again, as this is only one of three total layers of proxying (that I can see - there could be more), my ability to troubleshoot will be limited.

If you were to disable the Cloudflare proxy to our service I would be able to better troubleshoot any redirect issues. If there are other questions, please let us know.

Hi @luke, I’ve temporarily disabled Cloudflare’s proxy as requested, both on the main site and on the forum itself.

Hi, @chrism2671. I’m seeing identical content returned for both URLs:

$ curl -so proxied.html
$ curl -so not-proxied.html
$ md5sum proxied.html not-proxied.html
e2f0ccec93908fbb4c954526321e193f  proxied.html
e2f0ccec93908fbb4c954526321e193f  not-proxied.html

However, the proxied page has a number of 404s for resources on the page due to how those resources are referenced (specifically because they use absolute paths instead of relative paths).

For example, I’m going to examine these two CSS files from the HTML:

$ cat proxied.html | egrep "desktop.*css"
      <link href="/stylesheets/desktop_8c529eaf570fc46d537b4656831311379e69f7fa.css?" media="all" rel="stylesheet" data-target="desktop" data-theme-id="11"/>
      <link href="/stylesheets/desktop_theme_11_9e5c410efbccf422b37167e99ff1e11bcd253576.css?" media="all" rel="stylesheet" data-target="desktop_theme" data-theme-id="11"/>

For the proxied site, the paths above are:

However, the correct paths are this:

If the paths to the files were listed as this:

      <link href="./stylesheets/desktop_8c529eaf570fc46d537b4656831311379e69f7fa.css?" media="all" rel="stylesheet" data-target="desktop" data-theme-id="11"/>
      <link href="./stylesheets/desktop_theme_11_9e5c410efbccf422b37167e99ff1e11bcd253576.css?" media="all" rel="stylesheet" data-target="desktop_theme" data-theme-id="11"/>

or like this:

      <link href="stylesheets/desktop_8c529eaf570fc46d537b4656831311379e69f7fa.css?" media="all" rel="stylesheet" data-target="desktop" data-theme-id="11"/>
      <link href="stylesheets/desktop_theme_11_9e5c410efbccf422b37167e99ff1e11bcd253576.css?" media="all" rel="stylesheet" data-target="desktop_theme" data-theme-id="11"/>

then this would be treated as a relative path and the browser would request this path:


However, because an absolute path is used the /f/ prefix directory is dropped and the URLs requested are 404s.

To summarize, your site’s HTML is designed so that it no longer works when the site is proxied to under a different “sub-directory”. The HTML of your page uses absolute paths so the referenced assets don’t exist where the HTML says they do once proxied to under /f/. One solution for this is to use relative paths for the page assets.

If there are other questions about this, please let us know.

Thank you @luke, this is super helpful! I think I’ll be able to debug it with this.

Thanks so much! :slight_smile: