Preview pane uses local docker container IP address


(Hassan Farid) #1

It looks like the preview pane when creating a new topic is broken. Inspecting via the browser console says the markdown-it-bundle…js script fails to load because of a timed out connection. Unlike other assets, this is being looked up through the IP address rather than the domain name: http://172.17.0.5/assets/markdown-it-bundle-fb0211dacd14c5223c2336cabe82bfaf9cf84e82cb3f328ff2d8a216d1d89fa9.js

I’d guess this is failing because the URL needs a port number if using the IP address.

Deployment Information:
I am using a single node docker deployment of discourse. I have set these 3 variables in container/app.yml

  1. DISCOURSE_HOSTNAME: sub.domain.com
  2. DISCOURSE_HOST_IP: {docker-host-IP}
  3. DOCKER_USE_HOSTNAME: true

(Felix Freiberger) #2

That looks weird. With Google, I can only find 4 references to this variable in the whole internet, and one of them is this thread :wink:

Can you try removing that and rebuilding? If this doesn’t fix it: Are you behind a reverse proxy?


(Hassan Farid) #3

After reading your post, and your question on reverse proxy. I quickly checked my Discourse instance with IP address of docker-host:PORT. I found that preview panel works as expected in this case.

I could say it is not working as expected, when I am accessing via domain name that lands on docker-host and reverse proxied to specific port using nginx. Can you suggest what maybe causing this?

Here is the configuration of nginx for this domain.

server {
listen 80;
server_name domain_name;
location {
proxy_pass http://172.17.0.5;
}
}


(Felix Freiberger) #4

Aha, your nginx configuration is missing critical headers! Please look at this guide:

Once you add the following lines to your configuration and reload it, problem should be resolved :slight_smile:


(Hassan Farid) #5

Thanks @fefrei. That was helpful, and solved the problem.

Just to mention here, I have setup nginx as container on same host which is doing the reverse proxy.