# Discourse behind reverse proxy and https

**URL:** https://meta.discourse.org/t/discourse-behind-reverse-proxy-and-https/148705
**Category:** Self-hosting
**Created:** [April 21, 2020, 6:58am UTC](https://meta.discourse.org/t/discourse-behind-reverse-proxy-and-https/148705 "2020-04-21T06:58:13Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![neounix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neounix/32/215617_2.png) [@neounix](https://meta.discourse.org/u/neounix)
#### Post date: [April 21, 2020, 8:16am UTC](https://meta.discourse.org/t/discourse-behind-reverse-proxy-and-https/148705/3 "2020-04-21T08:16:33Z")

</div>

> [@Grunskin](#):
>
> Checking the `force https` flag in Discourse doesn’t help either, it will just break the site since it will just ignore everything over http.  
> What should I do to get rid of the mixed content?

I got Apache2 working “no problem” in a test bed with Apache2 as a reverse proxy to a unix socket in the container:

The only difference I found (note: only a few hours of testing, nothing complete) was:

- Apache2 will not work with with a symlink to the unix socket in the shared volume in the container;
- Apache2 was a bit slower in a rough test, but not by much.

Personally, I’m not a fan of religious wars over technologies; so I disagree that “Apache2 will give you a lot of issues.” **I did not experience any negative issues with Apache2 during my tests.**

Here is the core setup I used with Apache2 (HTTP, worked fine with LETSENCRYPT, BTW):

```plaintext
# cat discourse.example.conf
<VirtualHost *:80>
  ServerAdmin webmaster@localhost
  ServerName discourse.example.com
  DocumentRoot /website/discourse

  RewriteEngine On
  ProxyPreserveHost On
  ProxyRequests Off
  ProxyPass / unix:/var/discourse/shared/socket-only/nginx.http.sock|http://localhost/
  ProxyPassReverse / unix:/var/discourse/shared/socket-only/nginx.http.sock|http://localhost/
  ErrorLog /var/log/apache2/discourse.error.log
  LogLevel warn
  CustomLog /var/log/apache2/discourse.access.log combined

  RewriteCond %{SERVER_NAME} =discourse.example.com
  RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

```

Note: The only time we experienced issues with HTTP being served even when `force_https` set was when files were missing in the `/uploads` directory, but this (of course) is not related to Apache2 v. nginx as a reverse proxy.

---

_[View the full topic](https://meta.discourse.org/t/discourse-behind-reverse-proxy-and-https/148705)._
