Skip to content

Reverse Proxy Setup

Florian Quirin edited this page Jan 10, 2020 · 15 revisions

Reverse Proxy Setup

-- UNDER CONSTRUCTION --

What is a reverse proxy and why do I need one?

A reverse proxy is lightweight server that acts as a central contact point for clients and distributes connection requests to any number of associated servers that are usually not accessible by a client. In addition it usually offers security features like rate-limiting or handling of SSL certificates.
SEPIA for example requires a reverse proxy if you want to access it safely from a public domain (e.g. example.com/sepia).

Apache example setup for SEPIA

Many thanks to 'klausw' from the FHEM forum.
Create a new file at /etc/apache2/sites-available/sepia.conf and add the following content:

Define LOCATION sepia
Define HOST localhost

ProxyPass /${LOCATION}/assist/ http://${HOST}:20721/
ProxyPass /${LOCATION}/teach/ http://${HOST}:20722/

<Location /${LOCATION}/chat/>
  ProxyPass http://${HOST}:20723/

  RewriteEngine On
  RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
  RewriteCond %{HTTP:CONNECTION} Upgrade$ [NC]
  RewriteRule /messages/(.*) ws://${HOST}:20723/messages/$1 [P]
</Location>

Adjust the line Define HOST localhost according to the IP address of your SEPIA server(s) if the Apache proxy is not running on the same machine. Then load the new settings and restart your Apache web-server:

sudo a2ensite sepia.conf
sudo systemctl reload apache2