# How to run Discourse in Apache vhost, not Nginx

**URL:** https://meta.discourse.org/t/how-to-run-discourse-in-apache-vhost-not-nginx/133112
**Category:** Self-hosting
**Tags:** unsupported-install
**Created:** [11 בנובמבר,‏ 2019,‏ 2:18pm UTC](https://meta.discourse.org/t/how-to-run-discourse-in-apache-vhost-not-nginx/133112 "2019-11-11T14:18:14Z")
**Posts on this page:** 11
**Page:** 2

<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: [12 בנובמבר,‏ 2019,‏ 3:19pm UTC](https://meta.discourse.org/t/how-to-run-discourse-in-apache-vhost-not-nginx/133112/21 "2019-11-12T15:19:51Z")

</div>

> [@maltfield](#):
>
> _actual_ `install-nginx` script used by the container

The container in the host **never** runs `install-nginx` as said above.

---

<div class="post-metadata">

### Author: ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)
#### Post date: [12 בנובמבר,‏ 2019,‏ 3:26pm UTC](https://meta.discourse.org/t/how-to-run-discourse-in-apache-vhost-not-nginx/133112/22 "2019-11-12T15:26:50Z")

</div>

I’m not sure this topic is particularly useful.

You dislike the architecture of Discourse, won’t accept the word of the developers on the ways in which the product is optimized, you don’t appear to be familar with Docker and by your own admission are lying in your questions which is wasting our time collectively.

This topic already has an #unsupported-install tag because you’re straying far from the scope of the free support provided to the community. If this stuff really matters to you why not start a topic over on #Marketplace - then that way you can invest your own money paying a consultant to educate, rather than our time.

---

<div class="post-metadata">

### Author: ![maltfield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/maltfield/32/160669_2.png) [@maltfield](https://meta.discourse.org/u/maltfield)
#### Post date: [12 בנובמבר,‏ 2019,‏ 3:28pm UTC](https://meta.discourse.org/t/how-to-run-discourse-in-apache-vhost-not-nginx/133112/23 "2019-11-12T15:28:27Z")

</div>

> [@Stephen](#):
>
> You need to use hooks to amend the file from your `app.yml`
> 
> Have you worked with docker before?

I haven’t, sorry. So I need to put the above `sed` commands in the hooks section of app.yml? Is there an example somewhere for how to do that to modify a file in the `docker_discourse` repo at bootstrap? Currently that section only has a `git clone` command for plugins.

I could probably drop those `sed` commands in a `cmd` section like the `git clone` is, but I don’t know which dir where the `install-nginx` script will live..

Also, where does `app.yml` live? I couldn’t link to the `hooks` section above as the `containers` dir is empty in the repo 😕

- [discourse\_docker/containers at master · discourse/discourse\_docker · GitHub](https://github.com/discourse/discourse_docker/tree/master/containers)

---

<div class="post-metadata">

### Author: ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)
#### Post date: [12 בנובמבר,‏ 2019,‏ 3:31pm UTC](https://meta.discourse.org/t/how-to-run-discourse-in-apache-vhost-not-nginx/133112/24 "2019-11-12T15:31:12Z")

</div>

All of the documentation to do these things exists here on meta. We all like to skip reading the manual, but in this case you really should be going back to basics.

You’re going about all of this backwards frankly.

I’m going to point back to the #unsupported-install tag - the expectation is that if you decide to deviate from the [standard install](https://meta.discourse.org/t/142537?silent=true) you will assume the additional technical burden yourself.

> [@maltfield](#):
>
> Also, where does `app.yml` live? I couldn’t link to the `hooks` section above as the `containers` dir is empty in the repo 😕

How did you install the instance?

---

<div class="post-metadata">

### Author: ![maltfield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/maltfield/32/160669_2.png) [@maltfield](https://meta.discourse.org/u/maltfield)
#### Post date: [12 בנובמבר,‏ 2019,‏ 3:35pm UTC](https://meta.discourse.org/t/how-to-run-discourse-in-apache-vhost-not-nginx/133112/25 "2019-11-12T15:35:38Z")

</div>

> [@Stephen](#):
>
> We all like to skip reading the manual, but in this case you really should be going back to basics.

Sorry, but I do make an effort to search for documentation before posting. I’d _love_ a Discourse manual, and I’ve read through many of the topics tagged #howo already. Unfortunately, there doesn’t appear to be a Discourse manual..

I do appreciate your help with this, and I’m sure it will help others in the future who are searching for documentation on how to do these things…

> [@Stephen](#):
>
> How did you install the instance?

First `discourse-setup`, which ultimately gave me a broken install. Then manually editing `app.yml` followed by `./launcher rebuild app`

---

<div class="post-metadata">

### Author: ![marianord](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/marianord/32/90502_2.png) [@marianord](https://meta.discourse.org/u/marianord)
#### Post date: [12 בנובמבר,‏ 2019,‏ 4:21pm UTC](https://meta.discourse.org/t/how-to-run-discourse-in-apache-vhost-not-nginx/133112/26 "2019-11-12T16:21:01Z")

</div>

I think this is an interesting discussion, just to get to know Discourse better.

I’d go with nginx, maybe modify the `app.yml` enough to add the `mod_security` module in the compiling process, and have _my own_ base image built.

Now, Discourse is a complex piece of software, that runs on Rails that is even more complex to deploy easily and consistently, that’s why the staff has gone the extra mile in the Docker image they make.

The image has a lot of blackmagic happening, with tons and tons of optimizations just to run as good as possible in the supported install.

Knowing that, and being able to get all the pieces of the puzzle figured out (like, the 2-3 repositories needed to have Discourse running). It isn’t impossible to get what you want runnig.

Now, Knowing that your setup is `nginx -> varnish -> apache`, why don’t you run `nginx -> varnish -> Discourse` having the `mod_security` added to the base image and setup with hooks.

---

<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: [12 בנובמבר,‏ 2019,‏ 4:33pm UTC](https://meta.discourse.org/t/how-to-run-discourse-in-apache-vhost-not-nginx/133112/27 "2019-11-12T16:33:23Z")

</div>

The likelihood that `mod_security` will increase your security is very, very, small. The people who maintain Discourse are very concerned with security, so the things that `mod_security` is supposed to fix are likely taken care of already. Further, the likelihood that if you were to get `mod_security` added to your image, it will make Discourse inoperable is significantly greater than zero. If you do install `mod_security` and find that Discourse won’t work, you’ll then be on your own to modify Discourse to work with `mod_security` and either convince the discourse maintainers that you have found a legitimate security concern or be forced to maintain your own fork going forward.

~~No good can come from this.~~ It is highly improbable that any good can come from this.

---

<div class="post-metadata">

### Author: ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)
#### Post date: [12 בנובמבר,‏ 2019,‏ 7:14pm UTC](https://meta.discourse.org/t/how-to-run-discourse-in-apache-vhost-not-nginx/133112/28 "2019-11-12T19:14:49Z")

</div>

Agreed, another WAF borders on security by obscurity.

Real proactive efforts to keep discourse secure are being made:

> **[Discourse - Bug Bounty Program | HackerOne](https://hackerone.com/discourse)**
>
> The Discourse Bug Bounty Program enlists the help of the hacker community at HackerOne to make Discourse more secure. HackerOne is the #1 hacker-powered security platform, helping organizations find and fix critical vulnerabilities before they can be...

---

<div class="post-metadata">

### Author: ![maltfield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/maltfield/32/160669_2.png) [@maltfield](https://meta.discourse.org/u/maltfield)
#### Post date: [17 בנובמבר,‏ 2019,‏ 1:41pm UTC](https://meta.discourse.org/t/how-to-run-discourse-in-apache-vhost-not-nginx/133112/29 "2019-11-17T13:41:24Z")

</div>

This topic has drifted from the original question of running discourse on apache (as opposed to a proxy back to nginx).

But I think a discussion on putting a WAF (mod\_security or otherwise) before Discourse is useful to the community, so I’ve created a distinct topic to specifically discuss Discourse + WAF here:

- [Discourse + Web Application Firewall (WAF) mod\_security](https://meta.discourse.org/t/discourse-web-application-firewall-waf-mod-security/133612)

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [13 באוגוסט,‏ 2023,‏ 9:50pm UTC](https://meta.discourse.org/t/how-to-run-discourse-in-apache-vhost-not-nginx/133112/30 "2023-08-13T21:50:52Z")

</div>



---

<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: [14 באוגוסט,‏ 2023,‏ 12:29am UTC](https://meta.discourse.org/t/how-to-run-discourse-in-apache-vhost-not-nginx/133112/31 "2023-08-14T00:29:00Z")

</div>



[Previous page](https://meta.discourse.org/t/how-to-run-discourse-in-apache-vhost-not-nginx/133112.md?page=1)
