Too many redirects when reverse proxying to Discourse from a different server


(Jeff Yeon) #1

I set up Discourse on the domain discuss.example.com and i’m trying to make it so that realsite.com/discuss (different machine) proxies the request to discuss.example.com/discuss. I’ve already set up the subdirectory according to Subfolder support with Docker and it’s working fine. e.g discuss.example.com/discuss works.

However I’m struggling to set up the proxy on Nginx on the server that is proxying.

location ~/discuss(.*)$ {
    proxy_set_header X-Real-IP  $remote_addr;
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_set_header Host $host;
    proxy_pass https://discuss.example.com;
    # I also tried this among others
    # proxy_pass https://discuss.example.com$1;
}

It’s hitting the Discourse server according to top but i’m getting a ERR_TOO_MANY_REDIRECTS error attempting to go to realsite.com/discuss. I’m 90% sure it’s not an Nginx problem because the request is coming in from the Discourse side, but it’s causes too many redirects. I’m guessing it has something to do with the subdirectory redirect on Discourse. E.g. I go to discuss.example.com and it redirects to discuss.example.com/discuss.