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

**URL:** https://meta.discourse.org/t/putting-a-discourse-development-server-behind-proxy-seems-to-mess-up-some-but-not-most-urls/40829
**Category:** Development
**Created:** [9 Março , 2016 21:14 UTC](https://meta.discourse.org/t/putting-a-discourse-development-server-behind-proxy-seems-to-mess-up-some-but-not-most-urls/40829 "2016-03-09T21:14:49Z")
**Posts on this page:** 18
**Page:** 1

<div class="post-metadata">

### Author: ![ryantm](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ryantm/32/134063_2.png) [@ryantm](https://meta.discourse.org/u/ryantm)
#### Post date: [9 Março , 2016 21:14 UTC](https://meta.discourse.org/t/putting-a-discourse-development-server-behind-proxy-seems-to-mess-up-some-but-not-most-urls/40829/1 "2016-03-09T21:14:49Z")

</div>

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:

`http://192.168.1.23/letter_avatar/ryantm/90/5_a4c6c7825becdf9b31d9ea60fd0b5bf6.png`

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

`http://localhost:3000/letter_avatar_proxy/v2/letter/r/9fc29f/40.png`

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

---

<div class="post-metadata">

### Author: ![mpalmer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mpalmer/32/45740_2.png) [@mpalmer](https://meta.discourse.org/u/mpalmer)
#### Post date: [9 Março , 2016 22:26 UTC](https://meta.discourse.org/t/putting-a-discourse-development-server-behind-proxy-seems-to-mess-up-some-but-not-most-urls/40829/2 "2016-03-09T22:26:21Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![ryantm](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ryantm/32/134063_2.png) [@ryantm](https://meta.discourse.org/u/ryantm)
#### Post date: [9 Março , 2016 23:34 UTC](https://meta.discourse.org/t/putting-a-discourse-development-server-behind-proxy-seems-to-mess-up-some-but-not-most-urls/40829/3 "2016-03-09T23:34:37Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![ryantm](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ryantm/32/134063_2.png) [@ryantm](https://meta.discourse.org/u/ryantm)
#### Post date: [9 Março , 2016 23:56 UTC](https://meta.discourse.org/t/putting-a-discourse-development-server-behind-proxy-seems-to-mess-up-some-but-not-most-urls/40829/4 "2016-03-09T23:56:42Z")

</div>

Here’s a screenshot of it:

 ![](https://global.discourse-cdn.com/meta/original/3X/3/7/3754db7d3b7558276d77e17673bf6cadd00a004d.png)

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [9 Março , 2016 23:59 UTC](https://meta.discourse.org/t/putting-a-discourse-development-server-behind-proxy-seems-to-mess-up-some-but-not-most-urls/40829/5 "2016-03-09T23:59:10Z")

</div>

Did you try rebaking?

 ![](https://global.discourse-cdn.com/meta/original/3X/1/d/1d9306f538a65d38cbf473cb8c8fbcadfaf26971.png)

also @eviltrout 🐛 ⏫

---

<div class="post-metadata">

### Author: ![ryantm](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ryantm/32/134063_2.png) [@ryantm](https://meta.discourse.org/u/ryantm)
#### Post date: [10 Março , 2016 00:02 UTC](https://meta.discourse.org/t/putting-a-discourse-development-server-behind-proxy-seems-to-mess-up-some-but-not-most-urls/40829/6 "2016-03-10T00:02:43Z")

</div>

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

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [10 Março , 2016 00:14 UTC](https://meta.discourse.org/t/putting-a-discourse-development-server-behind-proxy-seems-to-mess-up-some-but-not-most-urls/40829/7 "2016-03-10T00:14:53Z")

</div>

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

---

<div class="post-metadata">

### Author: ![ryantm](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ryantm/32/134063_2.png) [@ryantm](https://meta.discourse.org/u/ryantm)
#### Post date: [10 Março , 2016 00:36 UTC](https://meta.discourse.org/t/putting-a-discourse-development-server-behind-proxy-seems-to-mess-up-some-but-not-most-urls/40829/8 "2016-03-10T00:36:58Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [10 Março , 2016 00:37 UTC](https://meta.discourse.org/t/putting-a-discourse-development-server-behind-proxy-seems-to-mess-up-some-but-not-most-urls/40829/9 "2016-03-10T00:37:53Z")

</div>

> [@ryantm](#):
>
> It seems like the URLs for the quote avatars are being generated in a different way than the other avatars.

This is the relevant phrase.

Is this true @eviltrout?

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [10 Março , 2016 00:52 UTC](https://meta.discourse.org/t/putting-a-discourse-development-server-behind-proxy-seems-to-mess-up-some-but-not-most-urls/40829/10 "2016-03-10T00:52:23Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![ryantm](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ryantm/32/134063_2.png) [@ryantm](https://meta.discourse.org/u/ryantm)
#### Post date: [11 Março , 2016 00:08 UTC](https://meta.discourse.org/t/putting-a-discourse-development-server-behind-proxy-seems-to-mess-up-some-but-not-most-urls/40829/11 "2016-03-11T00:08:38Z")

</div>

![](https://global.discourse-cdn.com/meta/original/3X/4/6/46039cb2ef0b52b35e2f0c6673fd588d95722570.png)

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.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [11 Março , 2016 00:21 UTC](https://meta.discourse.org/t/putting-a-discourse-development-server-behind-proxy-seems-to-mess-up-some-but-not-most-urls/40829/12 "2016-03-11T00:21:33Z")

</div>

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

---

<div class="post-metadata">

### Author: ![ryantm](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ryantm/32/134063_2.png) [@ryantm](https://meta.discourse.org/u/ryantm)
#### Post date: [11 Março , 2016 00:59 UTC](https://meta.discourse.org/t/putting-a-discourse-development-server-behind-proxy-seems-to-mess-up-some-but-not-most-urls/40829/13 "2016-03-11T00:59:02Z")

</div>

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:

 ![](https://global.discourse-cdn.com/meta/original/3X/0/c/0c60f4ac4db6501782258318b30060447b5596c5.png)

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [11 Março , 2016 02:27 UTC](https://meta.discourse.org/t/putting-a-discourse-development-server-behind-proxy-seems-to-mess-up-some-but-not-most-urls/40829/14 "2016-03-11T02:27:17Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [11 Março , 2016 03:11 UTC](https://meta.discourse.org/t/putting-a-discourse-development-server-behind-proxy-seems-to-mess-up-some-but-not-most-urls/40829/15 "2016-03-11T03:11:29Z")

</div>

> [@ryantm](#):
>
> All the developer settings are at their defaults according to the settings page:

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

```plaintext
==> 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

---

<div class="post-metadata">

### Author: ![ryantm](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ryantm/32/134063_2.png) [@ryantm](https://meta.discourse.org/u/ryantm)
#### Post date: [11 Março , 2016 17:32 UTC](https://meta.discourse.org/t/putting-a-discourse-development-server-behind-proxy-seems-to-mess-up-some-but-not-most-urls/40829/16 "2016-03-11T17:32:29Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [11 Março , 2016 22:48 UTC](https://meta.discourse.org/t/putting-a-discourse-development-server-behind-proxy-seems-to-mess-up-some-but-not-most-urls/40829/17 "2016-03-11T22:48:00Z")

</div>

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

---

<div class="post-metadata">

### Author: ![ryantm](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ryantm/32/134063_2.png) [@ryantm](https://meta.discourse.org/u/ryantm)
#### Post date: [11 Março , 2016 23:51 UTC](https://meta.discourse.org/t/putting-a-discourse-development-server-behind-proxy-seems-to-mess-up-some-but-not-most-urls/40829/18 "2016-03-11T23:51:14Z")

</div>

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 - #11 by ryantm](https://meta.discourse.org/t/putting-a-discourse-development-server-behind-proxy-seems-to-mess-up-some-but-not-most-urls/40829/11)
