User ryantm reports that running Discourse behind an Nginx proxy in a development environment causes inconsistent URL generation. While most links work, specific elements like quote avatars and split topic links incorrectly use localhost:3000 as the host instead of the proxy’s IP address (192.168.1.23), making them inaccessible to other users 1, 8, 11.
The discussion explores potential causes. Suggestions include rebaking the site, which fails to resolve the issue 6, and checking developer settings or Vagrant port forwarding, 15 configurations. However, since ryantm is running a standard Rails server without Vagrant, these do not apply directly 13, 16.
The solution is provided by user riking, who advises setting force_hostname to the proxy IP and clearing the port setting in the developer configuration. This resolves the avatar URL issues after rebuilding post HTML, though a separate split topic link remains broken 18.
Hmm, interesting… it looks like the quote avatar URL is totally broken there, using localhost:3000 as the host is never the right idea. What version of Discourse are you running?
I don’t think its totally broken. localhost:3000 is where the development server is that I’m running. I’m running d34b4d3 (the latest Master). I might totally have something misconfigured, but I thought it was strange that some links were working and others were not.
Yes. The nginx server is running at 192.168.1.23:80 and it is proxying all connections to a discourse server running on localhost:3000 (via bundle exec rails s). When I connect to 192.168.1.23:80 from another computer, I see the regular discourse site, but the quote avatar images have a img url with a host of localhost:3000, which is not accessible to the other computer.
The link I circled in this screenshot is also using localhost:3000 as the host. That link is supposed to link to the topic this post was split off from.
I am running this discourse instance locally on my machine out of the git repository with bundle exec rails s. I can’t find any file called app.yml. I see references to it relating to docker containers. I am not using a docker container.
How do I find the “site name” when running in development?
All the developer settings are at their defaults according to the settings page:
If this is a development setup then this is a Dev topic, know that we do not support these port overrides on a production site. That is why there are so many warnings on those settings.
If you see the “3000 => 4000” try changing your Admin → Developer port from 3000 to 4000
You may need to “rebuild HTML” posts that have the broken links in them
I’m not using Vagrant; I’m just running it like I run any other rails app.
It really doesn’t make sense to me that most links / URLs work fine. There really must be some differences in how the links are generated. I think this is at least weird if not a bug.
This setup came up because I was quickly trying to prototype having nginx in front of Discourse. I will try it in a production setup to see if that solves my problem.