# Wanting to run Discourse alongside apache

**URL:** https://meta.discourse.org/t/wanting-to-run-discourse-alongside-apache/125075
**Category:** Self-hosting
**Created:** [August 7, 2019, 1:38am UTC](https://meta.discourse.org/t/wanting-to-run-discourse-alongside-apache/125075 "2019-08-07T01:38:18Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![koltl](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/koltl/32/152166_2.png) [@koltl](https://meta.discourse.org/u/koltl)
#### Post date: [August 7, 2019, 1:38am UTC](https://meta.discourse.org/t/wanting-to-run-discourse-alongside-apache/125075/1 "2019-08-07T01:38:18Z")

</div>

I have seen a couple of tutorials that explain how to do this but in different ways which does not help me. Is there a way to make a apache virtual host config for Discourse so that a specific domain redirects to the software just like adding other websites and respective domains?

Thank you.

---

<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 7, 2019, 2:12am UTC](https://meta.discourse.org/t/wanting-to-run-discourse-alongside-apache/125075/2 "2019-08-07T02:12:35Z")

</div>

Yes. Those tutorials explain how.

Or, if you mean can you run discourse without docker and having apache as a reverse proxy, the answer is no.

For $5/month you an avoid that pain.

---

<div class="post-metadata">

### Author: ![koltl](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/koltl/32/152166_2.png) [@koltl](https://meta.discourse.org/u/koltl)
#### Post date: [August 7, 2019, 2:17am UTC](https://meta.discourse.org/t/wanting-to-run-discourse-alongside-apache/125075/3 "2019-08-07T02:17:27Z")

</div>

Thanks for the reply.

I am running it off a VPS. I have Apache installed and I am not too experienced with websites. I am looking at 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)

But with that it seems like I have to use Nginx because of the config files, but my question is, can I do the same with but with Apache?

---

<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 7, 2019, 2:28am UTC](https://meta.discourse.org/t/wanting-to-run-discourse-alongside-apache/125075/4 "2019-08-07T02:28:35Z")

</div>

Have a look at [Set up Discourse on a server with existing Apache sites](https://meta.discourse.org/t/how-to-set-up-discourse-on-a-server-with-existing-apache-sites/30013)

---

<div class="post-metadata">

### Author: ![koltl](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/koltl/32/152166_2.png) [@koltl](https://meta.discourse.org/u/koltl)
#### Post date: [August 7, 2019, 2:31am UTC](https://meta.discourse.org/t/wanting-to-run-discourse-alongside-apache/125075/5 "2019-08-07T02:31:36Z")

</div>

Yeah I was looking at that too. He covered it for CentOS and not Ubuntu, some parts are unclear to me

---

<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 7, 2019, 2:38am UTC](https://meta.discourse.org/t/wanting-to-run-discourse-alongside-apache/125075/6 "2019-08-07T02:38:28Z")

</div>

> [@koltl](#):
>
> I have Apache installed and I am not too experienced with websites.

If you aren’t familiar with this (and don’t want to become), I really recommend ditching Apache and running only Discourse in the VPS. If you need to run more stuff, get a VPS for Apache stuff and another for Discourse.

---

<div class="post-metadata">

### Author: ![koltl](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/koltl/32/152166_2.png) [@koltl](https://meta.discourse.org/u/koltl)
#### Post date: [August 7, 2019, 10:47pm UTC](https://meta.discourse.org/t/wanting-to-run-discourse-alongside-apache/125075/7 "2019-08-07T22:47:05Z")

</div>

So I switched over to Nginx and everything is working. I believe SSL is setup properly but on chrome, it gives me the message “Your connection to this site is not fully secure”. Force HTTPs is on

---

<div class="post-metadata">

### Author: ![lucasbasquerotto](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lucasbasquerotto/32/133376_2.png) [@lucasbasquerotto](https://meta.discourse.org/u/lucasbasquerotto)
#### Post date: [August 7, 2019, 11:28pm UTC](https://meta.discourse.org/t/wanting-to-run-discourse-alongside-apache/125075/8 "2019-08-07T23:28:03Z")

</div>

The SSL is setup with the nginx service **inside** the container. If the container is exposed to the internet and you access it directly from the browser (default discourse installation), you will have SSL.

But if you put a reverse proxy in front of it (be it Apache, Nginx, or some 3rd party service, like Cloudflare), you will have to ensure that the connection **between the browser and the reverse proxy is secure**.

So, in your case, you will have to generate certificates for the nginx reverse proxy (I don’t think you need to add the SSL templates from discourse because the container is not exposed directly to the internet; you can, but don’t need).

You can take a look in how to do that using [Let’s Encrypt](https://letsencrypt.org/) (free, the same that is used in the default installation of Discourse, but in this case for the nginx outside the container).

**TL;DR** The nginx that acts as a reverse proxy needs SSL. The nginx that is inside the container doesn’t need SSL (assuming you are accessing from the same machine).

---

<div class="post-metadata">

### Author: ![koltl](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/koltl/32/152166_2.png) [@koltl](https://meta.discourse.org/u/koltl)
#### Post date: [August 8, 2019, 12:33am UTC](https://meta.discourse.org/t/wanting-to-run-discourse-alongside-apache/125075/9 "2019-08-08T00:33:08Z")

</div>

So to have security between browser and reverse proxy, I need to configure SSL in the nginx configuration file?

Thanks

---

<div class="post-metadata">

### Author: ![koltl](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/koltl/32/152166_2.png) [@koltl](https://meta.discourse.org/u/koltl)
#### Post date: [August 8, 2019, 1:22pm UTC](https://meta.discourse.org/t/wanting-to-run-discourse-alongside-apache/125075/10 "2019-08-08T13:22:43Z")

</div>

This is my config here, what else do I need to add?

```nginx
server {
    listen 80; listen [::]:80;
    server_name a1rp.xyz; # <-- change this

    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl http2; listen [::]:443 ssl http2;
    server_name a1rp.xyz; # <-- change this

    ssl on;
    ssl_certificate /var/discourse/shared/standalone/ssl/a1rp.xyz.cer;
    ssl_certificate_key /var/discourse/shared/standalone/ssl/a1rp.xyz.key;
    ssl_dhparam /var/discourse/shared/standalone/ssl/dhparams.pem;
    ssl_session_tickets off;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:ECDHE-RSA-DES-CBC3-SHA:ECDHE-ECDSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA;

    http2_idle_timeout 5m; # up from 3m default

    location / {
        proxy_pass http://unix:/var/discourse/shared/standalone/nginx.http.sock;
        proxy_set_header Host $http_host;
        proxy_http_version 1.1;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto https;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

```

---

<div class="post-metadata">

### Author: ![lucasbasquerotto](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lucasbasquerotto/32/133376_2.png) [@lucasbasquerotto](https://meta.discourse.org/u/lucasbasquerotto)
#### Post date: [August 8, 2019, 1:42pm UTC](https://meta.discourse.org/t/wanting-to-run-discourse-alongside-apache/125075/11 "2019-08-08T13:42:57Z")

</div>

Make sure to:

1. Comment out all ssl templates in the `templates` (in `app.yml`) . If you are using letsencrypt you will have two:

```plaintext
# - "templates/web.ssl.template.yml"
# - "templates/web.letsencrypt.ssl.template.yml"

```

1. Add a socket template:

```plaintext
- "templates/web.socketed.template.yml" 

```

1. Comment out all exposed ports:

```plaintext
# - "80:80" # http
# - "443:443" # https

```

(or you may expose other ports like `8080:80` and `8443:443` and instead of using a socket in the next step you can redirect to an upstream that points to `localhost:80` and/or `localhost:443`)

1. You have:

```plaintext
proxy_pass http://unix:/var/discourse/shared/standalone/nginx.http.sock;

```

I think you need to add **:** at the end of the socket:

```plaintext
proxy_pass http://unix:/var/discourse/shared/standalone/nginx.http.sock:;

```

1. You need to have the ssl certificate files at `/var/discourse/shared/standalone/ssl/`. Do you have them? I’m assuming you already own the domain `a1rp.xyz` and read about how to generate ssl certificates in the letsencrypt site. Also keep in mind that discourse handles the renewal of certificates for you in the default install, but in you case you would have to handle it (with a cronjob, for example), otherwise your certificates will expire after 3 months.

See:

> [@Run other websites on the same machine as Discourse](https://meta.discourse.org/t/running-other-websites-on-the-same-machine-as-discourse/17247/182):
>
> The guide in the first post is great and, on the whole, still works just fine sunny There are three things worth noting: I initially missed some of the app.yml changes. There are 3 things you need to change in your app.yml. If you miss any of these things it won’t work: Comment out all ssl templates in the templates. If you are using letsencrypt you will have two:# - "templates/web.ssl.template.yml" # - "templates/web.letsencrypt.ssl.template.yml" Add a socket template:- "templates/web…

---

<div class="post-metadata">

### Author: ![koltl](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/koltl/32/152166_2.png) [@koltl](https://meta.discourse.org/u/koltl)
#### Post date: [August 8, 2019, 3:37pm UTC](https://meta.discourse.org/t/wanting-to-run-discourse-alongside-apache/125075/12 "2019-08-08T15:37:44Z")

</div>

Yeah I have all of what you said to do in the app config (including the post correcting some things). As far as the :, I don’t think it makes a difference. There was a post saying there shouldn’t be a : there too. The SSL files I also already have

---

<div class="post-metadata">

### Author: ![koltl](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/koltl/32/152166_2.png) [@koltl](https://meta.discourse.org/u/koltl)
#### Post date: [August 8, 2019, 4:07pm UTC](https://meta.discourse.org/t/wanting-to-run-discourse-alongside-apache/125075/13 "2019-08-08T16:07:14Z")

</div>

So I fixed the problem. Someone mentioned the favicon showing in http which is why it gave the error. I uploaded something else and deleted it, now the site is fully https 🙂

---

<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: [September 7, 2019, 4:15pm UTC](https://meta.discourse.org/t/wanting-to-run-discourse-alongside-apache/125075/14 "2019-09-07T16:15:20Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
