Forwarding to Discourse container with nginx proxy_pass and links from Discourse to host server

Hi Discouse Team,

I am running an nginx server on my host machine and a pretty standard Discourse container in Docker. Basically, I have a small number of specific (http) folders served by the host nginx, and everything else is forwarded to the Discourse container via proxy_pass.

As far as I understand the issue, its sufficient to understand that my host nginx conf file defines a location /xyz, which is handled by the host nginx, and then a location / is defined to be proxy_pass’ed to the Discourse container.

For my use case, I need to post links as Discourse postings pointing to my.domaiin.com/xyz/some.html, i.e., Links inside Discourse are pointing to pages served by the host nginx.

That worked until the last Discourse update. Now clicking on the links end up in the Discourse “could not find…” page. In contrast, copying Link targets and opening them in a new tab works as expected.

I have quite some understanding about low level protocols, but the higher it gets in the protocol stack, the less I know :wink:
Currrent working hypthesis is that Discourse nginx keeps the connection open (keepalive?), so the host nginx misses the opportunity parsing the new request path to select the correct server. Connection’s requests are passed to the container as is kept alive. Then the request for path /xyz is answered by Discourse who does not know this folder…

How should I approach this issue? If there is no simple solution, it would already help to get some pointers, even a good description with respect to decent http protocol knowledge might help.

Thanks!

Additional note: If this is really a keep-alive issue, I am totally fine disabling keep-alive and accepting some cost overhead. This installation is not meant so serve a huge number of users.

Thinking about it, I probably need to make the host nginx also listening to a named pipe, expose this pipe into the Discourse container and add my custom folder /xyz to the Discourse nginx conf, to proxy_pass it back through the newly created pipe. (After having resolved the details, e.g. host nginx needs to start first, otherwise docker-compose will not properly expose the named pipe)

Still, any help appreciated :wink:

This is due to the Ember.JS router knowing the complete list of paths supported by the Discourse application, and the 404 page is being rendered clientside because it knows the server has no content there.

Place your files on another subdomain.

4 Likes