# Non-standard port breaks uploads

**URL:** https://meta.discourse.org/t/non-standard-port-breaks-uploads/49022
**Category:** Self-hosting
**Tags:** uploads
**Created:** [August 22, 2016, 7:05pm UTC](https://meta.discourse.org/t/non-standard-port-breaks-uploads/49022 "2016-08-22T19:05:04Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [August 22, 2016, 7:05pm UTC](https://meta.discourse.org/t/non-standard-port-breaks-uploads/49022/1 "2016-08-22T19:05:04Z")

</div>

Following [this guide](https://meta.discourse.org/t/how-to-set-up-discourse-on-a-server-with-existing-apache-sites/30013) I setup Discourse alongside multiple existing sites on my server. All the previous sites (as well as Discourse) are able to run, and seem to work fine, but images are broken in Discourse. The images are uploaded to `$hostname/uploads`, but the correct URL would be `$hostname:8888/uploads`. I can’t find where in site settings of my yml file to fix this.

---

<div class="post-metadata">

### Author: ![elijah](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elijah/32/104055_2.png) [@elijah](https://meta.discourse.org/u/elijah)
#### Post date: [August 22, 2016, 7:31pm UTC](https://meta.discourse.org/t/non-standard-port-breaks-uploads/49022/2 "2016-08-22T19:31:19Z")

</div>

> [@User avatars are not displaying](https://meta.discourse.org/t/user-avatars-are-not-displaying/46683/2):
>
> Discourse doesn’t support running on a non standard port, so choose 80 or 443. (ps: choose 443 with free ssl)

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [August 22, 2016, 8:54pm UTC](https://meta.discourse.org/t/non-standard-port-breaks-uploads/49022/3 "2016-08-22T20:54:16Z")

</div>

OK, so if that #howto is not proper practice, do you know how to run Discourse alongside existing Apache sites?

---

<div class="post-metadata">

### Author: ![elijah](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elijah/32/104055_2.png) [@elijah](https://meta.discourse.org/u/elijah)
#### Post date: [August 22, 2016, 8:57pm UTC](https://meta.discourse.org/t/non-standard-port-breaks-uploads/49022/4 "2016-08-22T20:57:37Z")

</div>

I don’t think that how-to is by Discourse staff. You could ask in that topic and maybe that would trigger response by the how-to author.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [August 22, 2016, 9:03pm UTC](https://meta.discourse.org/t/non-standard-port-breaks-uploads/49022/5 "2016-08-22T21:03:54Z")

</div>

From my read of that guide, it uses HAProxy in front of Apache, so Discourse listen on port 80 in the end.

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [August 22, 2016, 9:05pm UTC](https://meta.discourse.org/t/non-standard-port-breaks-uploads/49022/6 "2016-08-22T21:05:20Z")

</div>

Then I am obviously doing something wrong…simply loading the hostname puts me at my sites index.html, I have no way of getting to Discourse without a specific port. I must be missing something here…

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [August 22, 2016, 9:08pm UTC](https://meta.discourse.org/t/non-standard-port-breaks-uploads/49022/7 "2016-08-22T21:08:42Z")

</div>

That’s my read too. Discourse is exposed on some other port on the Host, but the proxy needs to map [x.example.com](http://x.example.com) to the Discourse instance.

@jomaxro, can you add another domain (like [community.example.com](http://community.example.com)) to your config and tell the proxy to proxy requests for [community.example.com](http://community.example.com) to localhost:8888? Does that make sense?

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [August 22, 2016, 9:10pm UTC](https://meta.discourse.org/t/non-standard-port-breaks-uploads/49022/8 "2016-08-22T21:10:47Z")

</div>

The concept makes sense, but in practice I am lost. Which config am I adding to, apache or haproxy? Also, I don’t have control of the domain, I have [xyz.abc.123.edu](http://xyz.abc.123.edu), and that’s it.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [August 22, 2016, 9:21pm UTC](https://meta.discourse.org/t/non-standard-port-breaks-uploads/49022/9 "2016-08-22T21:21:53Z")

</div>

It’s in the HAProxy, I believe.

These lines are the magic:

```plaintext
        acl host_discourse hdr(host) -i my_discourse_site.com
        # figure out which one to use
        use_backend discourse_docker if host_discourse

```

If you have lots of sites, you’ll need to add more `acl` lines and more `use xx if host_yyy` lines.

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [August 22, 2016, 9:25pm UTC](https://meta.discourse.org/t/non-standard-port-breaks-uploads/49022/10 "2016-08-22T21:25:48Z")

</div>

Here’s my current HAProxy:

```plaintext
        timeout queue 1m
        timeout connect 10s
        timeout client 1m
        timeout server 1m
        timeout http-keep-alive 10s
        timeout check 10s
        maxconn 3000
frontend http-in
        bind *:80
        default_backend main_apache_sites/html
        # Define hosts
        acl host_discourse hdr(host) -i leet.arc.rpi.edu
        # figure out which one to use
        use_backend discourse_docker if host_discourse

backend main_apache_sites
    server server1 127.0.0.1:8080 cookie A check
backend discourse_docker
    server server2 127.0.0.1:8888 cookie A check

```

Note, host is not connected to internet, you must be on campus network to connect. All the other (existing) sites are behind Apache, so I don’t think I need more `acl` lines.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [August 22, 2016, 10:25pm UTC](https://meta.discourse.org/t/non-standard-port-breaks-uploads/49022/11 "2016-08-22T22:25:52Z")

</div>

I’d be stumped too. 🙂

Oh. Maybe you need to make sure that Apache isn’t doing something to enforce the port mapping? Are you sure that HAProxy and not Apache is what’s answering the door? (Maybe shutdown apache, restart HAPRoxy and then start apache?)

---

<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: [August 22, 2016, 11:07pm UTC](https://meta.discourse.org/t/non-standard-port-breaks-uploads/49022/12 "2016-08-22T23:07:17Z")

</div>

I’m not understanding the root problem. Why would "the correct URL would be `$hostname:8888/uploads` – all access to the site should be via HAProxy, as I understand it, so why would the correct URL have the port in it?

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [August 22, 2016, 11:42pm UTC](https://meta.discourse.org/t/non-standard-port-breaks-uploads/49022/13 "2016-08-22T23:42:15Z")

</div>

I think I’m causing all the confusion here as I’m the one confused. Let me try and clear things up.

##Before Discourse:  
3 sites were hosted on a local server, `http://leet.arc.rpi.edu`. quicklogs, mediawiki, and printers were located at `/quicklogs`, `/wiki`, and `/printerpicker` respectively. There was also an `index.html` at the root of the server which included links to each of the 3 sites, as well as a few external resourses.

##Discourse Install:  
Installed Discourse using the 30-minute guide, then followed above linked guide to put alongside existing sites. End goal is for staff to continue using “leet” as their homepage, and linking to each tool. As such, Discourse would exist (somewhere) and would be linked by the index.html.

##Problem:  
Currently I can only access Discourse by adding `:8888` to the url. I am unsure how to access it otherwise.

---

<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: [August 23, 2016, 12:19am UTC](https://meta.discourse.org/t/non-standard-port-breaks-uploads/49022/14 "2016-08-23T00:19:25Z")

</div>

OK, what you need then is not the subdomain install you’re kinda-sorta putting together now, but a [subfolder install](https://meta.discourse.org/t/subfolder-support-with-docker/30507). Then, it’d probably be best just to throw out haproxy altogether and configure Apache to proxy `<Location /forum>` to `localhost:8888` (or wherever you’ve got Discourse mapped to).

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [August 23, 2016, 12:23am UTC](https://meta.discourse.org/t/non-standard-port-breaks-uploads/49022/15 "2016-08-23T00:23:50Z")

</div>

So just to make sure I am understanding completely, I should do the following:

1. Remove HAProxy entirely.
2. Remove Listen commands from Apache config files.
3. Follow Neil’s guide to put Discourse in a subfolder.
4. Use apache to proxy to Discourse.

---

<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: [August 23, 2016, 12:28am UTC](https://meta.discourse.org/t/non-standard-port-breaks-uploads/49022/16 "2016-08-23T00:28:36Z")

</div>

A more generalised step 1+2 would be, “revert _everything_ you’ve done according to the “existing apache sites” howto”. But yes, what you’ve described is what needs to be done.

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [August 24, 2016, 3:34am UTC](https://meta.discourse.org/t/non-standard-port-breaks-uploads/49022/17 "2016-08-24T03:34:17Z")

</div>

Matt, thanks for all your help (and Jay, and Rafael). I was able to successfully get my instance up and running, and have run into no further issues thus far!

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [August 24, 2016, 3:50am UTC](https://meta.discourse.org/t/non-standard-port-breaks-uploads/49022/18 "2016-08-24T03:50:18Z")

</div>

…and it looks like I may have spoken too soon.

Unknown if this is related to subfolder install, discourse being on a custom port and proxied, or an actual bug - but when I went to /admin/upgrade and ran an update, the progress bar never filled nor did anything appear in the console below. After waiting 10 minutes, I reloaded the upgrade page and found that it had in fact upgraded.

Any thoughts?

---

<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: [August 24, 2016, 3:59am UTC](https://meta.discourse.org/t/non-standard-port-breaks-uploads/49022/19 "2016-08-24T03:59:54Z")

</div>

I’d have to say that by far the most likely cause of that would be a bug in the upgrade UI not handling subfolders with grace and aplomb. Any of my fellow [@team](https://meta.discourse.org/groups/team) members feel like spinning up a scratch subfolder install and seeing if this sucker’s reproducible?

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [August 24, 2016, 4:04am UTC](https://meta.discourse.org/t/non-standard-port-breaks-uploads/49022/20 "2016-08-24T04:04:52Z")

</div>

I’m no apache expert, but I remeber sam saying that you need to go an extra mile so it plays well with message\_bus too.

[Next page](https://meta.discourse.org/t/non-standard-port-breaks-uploads/49022.md?page=2)
