Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reverse Proxy Instructions #20

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/.vuepress/config.en-US.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ module.exports = {
'collaborative-logger',
'scripts',
'tests'
'reverse-proxy'
]
}
]
Expand Down
75 changes: 75 additions & 0 deletions docs/reverse-proxy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Reverse Proxy Setup

## Apache2

This allows you to access the Leon web app using an Apache virtual host.

## Prerequisites

- **A domain**
> DNS A (and/or AAAA) records have to point to your webserver.

- **SSL certificate**
> A valid SSL certificate.

> The setup is possible without SSL, though using HTTPS is highly recommended. The following configuration examples apply to a HTTPS enforced site.

- **An operating system**
> Obvious.

- **Apache2 / HTTPD**
> Apache2 needs to be installed, and the modules `mod_ssl`, `mod_proxy` as well as `mod_wstunnel` need to be loaded.
<br>Refer to the Apache documentation specific to your operating system to find the correct procedure on how to install and load modules as well as on how and where to define virtual hosts.

- **Firewall**
> If a firewall is in place, the ports 80 and 443 need to be opened and/or forwarded accordingly.
<br>If Leon resides on a different machine, the configured `LEON_PORT` needs to be reachable by the webserver.

- **Leon**
> A working Leon installation. It is recommended to test if Leon works as expected before attempting to troubleshoot issues with the reverse proxy.

> Warning - As of writing this document, the following configuration examples only apply to the DEVELOPMENT branch of Leon.
<br>Since this branch is deemed stable enough by the author, the complex procedure for setting a reverse proxy up with Leon from the Master branch (it involves tampering with the source files) will not be explained.

## Leon configuration (.env)

# Server
LEON_HOST=https://leon.example.com
LEON_PORT=1337

## Apache virtual host (leon.conf)

`leon.example.com` is the domain you will use to reach the Leon web app.

`127.0.0.1` is the machine the web server reaches the Leon backend on. If Leon resides on a different machine, replace this with the hostname or IP address of that machine.

`:1337` is the port the Leon backend listens on (you specified it above with `LEON_PORT`).


<VirtualHost *:80>
ServerName leon.example.com

RewriteEngine On
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]
</VirtualHost>
<VirtualHost *:443>
ServerName leon.example.com

SSLEngine On
SSLCertificateFile "/path/to/fullchain.pem"
SSLCertificateKeyFile "/path/to/privkey.pem

ProxyPreserveHost Off
ProxyPass / http://127.0.0.1:1337/
ProxyPassReverse / http://127.0.0.1:1337/

RewriteEngine On
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteCond %{HTTP:Connection} upgrade [NC]
RewriteRule ^/?(.*) "ws://127.0.0.1:1337/$1" [P,L]
</VirtualHost>


That's it!