Putting a discourse development server behind proxy seems to mess up some (but not most) URLs

I’m running nginx in front of Discourse with

upstream discourse {
  server localhost:3000;

server {
  listen 80 default_server;

  location / {
    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_pass http://discourse;


The avatar that appears to the left of the post has a url like:

but the avatar that appears in quotes in posts is a url like:


It seems like the URLs for the quote avatars are being generated in a different way than the other avatars.

1 Like

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.

Here’s a screenshot of it:

Did you try rebaking?

also @eviltrout :bug: :arrow_double_up:

Thanks for the suggestion. I just tried that and it stayed the same.

What is the difference between the 2 URLs, one that works and one that does not?

Yes. The nginx server is running at and it is proxying all connections to a discourse server running on localhost:3000 (via bundle exec rails s). When I connect to 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.

This is the relevant phrase.

Is this true @eviltrout?

1 Like

I don’t know if this is applicable to your case.

On my GitHub - VirtualBox - Vagrant localhost development set-up I had some problems with image URLs.

I needed to go to Admin -> Settings -> Developer and change “port” from the default 3000 to 4000

Knock-wood, no problems since.

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.

What is the site name in app.yml? And you’re not using any developer site settings are you?

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.

1 Like

That sounds like it is your problem. When you first run vagrant up look at the ports used

==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 3000 (guest) => 4000 (host) (adapter 1)
    default: 1080 (guest) => 4080 (host) (adapter 1)
    default: 22 (guest) => 2222 (host) (adapter 1)

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

1 Like

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.

Because you’re running in development, you need to set force hostname to and port to the empty string.

1 Like

Thanks! That fixed the quote avatar image urls (after rebuilding the html of the post), but not that split topic link I mentioned in Putting a discourse development server behind proxy seems to mess up some (but not most) URLs