# Deploying discourse on server already running another rails app

**URL:** https://meta.discourse.org/t/deploying-discourse-on-server-already-running-another-rails-app/38467
**Category:** Self-hosting
**Created:** [2016年一月25日 19:48 UTC](https://meta.discourse.org/t/deploying-discourse-on-server-already-running-another-rails-app/38467 "2016-01-25T19:48:34Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![adass](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/adass/32/49627_2.png) [@adass](https://meta.discourse.org/u/adass)
#### Post date: [2016年一月25日 19:48 UTC](https://meta.discourse.org/t/deploying-discourse-on-server-already-running-another-rails-app/38467/1 "2016-01-25T19:48:34Z")

</div>

Hi,

I am trying to deploy a docker discourse on a linux server already running an apache + passenger + rails application. First I thought it would be easy – just setup docker to use another port (8080), but then I found out that serving from non-default port creates some issues with assets like avatars [Hosting on a non-default port causes catch-22](https://meta.discourse.org/t/hosting-on-a-non-default-port-causes-catch-22/19279 "Hosting on a non-default port causes catch-22").

So, do you had similar issue? How did you resolved it? All suggestions are welcomed 😄

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [2016年一月25日 20:23 UTC](https://meta.discourse.org/t/deploying-discourse-on-server-already-running-another-rails-app/38467/2 "2016-01-25T20:23:47Z")

</div>

The usual setup is to use a reverse proxy listening on port 80 that (maybe does SSL and) routes requests to the different applications. It’s not too hard to set up, and we have a nice tutorial by @riking for this:

> [@Run other websites on the same machine as Discourse](https://meta.discourse.org/t/running-other-websites-on-the-same-machine-as-discourse/17247):
>
> @pfaffman edited this heavily 2022.02.24. Blame me if it’s broken. If you want to run other websites on the same machine as Discourse, you need to set up an extra NGINX or HAProxy proxy in front of the Docker container. NOTE: This is for advanced admins This guide assumes you already have Discourse working - if you don’t, it may be hard to tell whether or not the configuration is working. You cannot use ./discourse-setup to set up Discourse if another server is using port 80 or 443. You will…

---

<div class="post-metadata">

### Author: ![adass](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/adass/32/49627_2.png) [@adass](https://meta.discourse.org/u/adass)
#### Post date: [2016年一月26日 05:58 UTC](https://meta.discourse.org/t/deploying-discourse-on-server-already-running-another-rails-app/38467/3 "2016-01-26T05:58:57Z")

</div>

Thanks! I will have a look into this. One remark: my server is only accessible via IP number, so I would like to deploy discourse into a subfolder. Do you think this setup will work with reverse proxy apache module?

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [2016年一月26日 06:41 UTC](https://meta.discourse.org/t/deploying-discourse-on-server-already-running-another-rails-app/38467/4 "2016-01-26T06:41:59Z")

</div>

This should work, although Apache needs additional configuration for long polling to work, if I recall correctly. Nginx is easier to setup and likely a bit faster.

---

<div class="post-metadata">

### Author: ![adass](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/adass/32/49627_2.png) [@adass](https://meta.discourse.org/u/adass)
#### Post date: [2016年二月17日 11:42 UTC](https://meta.discourse.org/t/deploying-discourse-on-server-already-running-another-rails-app/38467/5 "2016-02-17T11:42:45Z")

</div>

So, I installed HAproxy and configured my discourse Docker for subfolder support. I took an [idea](https://meta.discourse.org/t/how-to-set-up-discourse-on-a-server-with-existing-apache-sites/30013) of configuring apache to listen to 8080 and docker on 8088 - not sure if it is possible to leave eg. docker on port 80 and somehow configure HAproxy to listen port 80 but route requests for subfolder docker installation to port 80. At first it seems like asking for an infinite loop, but I am not en expert with HAproxy 😊

Hovewer, my server is behing proxy blocking all outgoing internet traffic. I noticed that system assigned avatars are broken. Question now is it possible to restore this avatars with local assets or a proxy config for accessing outside of my local network?

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [2016年二月17日 11:56 UTC](https://meta.discourse.org/t/deploying-discourse-on-server-already-running-another-rails-app/38467/6 "2016-02-17T11:56:30Z")

</div>

> [@adass](#):
>
> Question now is it possible to restore this avatars with local assets

You can generate letter avatars locally – just disable the site setting `external system avatars enabled`. Note that this will slightly increase CPU load.

---

<div class="post-metadata">

### Author: ![adass](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/adass/32/49627_2.png) [@adass](https://meta.discourse.org/u/adass)
#### Post date: [2016年二月17日 11:59 UTC](https://meta.discourse.org/t/deploying-discourse-on-server-already-running-another-rails-app/38467/7 "2016-02-17T11:59:29Z")

</div>

Thanks! that resolved my avatar issue.

---

<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: [2016年二月17日 19:04 UTC](https://meta.discourse.org/t/deploying-discourse-on-server-already-running-another-rails-app/38467/8 "2016-02-17T19:04:15Z")

</div>

Note that also means that all embeds, eg YouTube videos, will not work.

(Actually YouTube might still work, but that’s an outlier, all the other embeds like Twitter and WordPress will be broken)

---

<div class="post-metadata">

### Author: ![adass](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/adass/32/49627_2.png) [@adass](https://meta.discourse.org/u/adass)
#### Post date: [2016年二月17日 19:38 UTC](https://meta.discourse.org/t/deploying-discourse-on-server-already-running-another-rails-app/38467/9 "2016-02-17T19:38:13Z")

</div>

That’s OK. I have no plan to take advantage of linking to resources outside my local network.
