4 Jan 2018

[Blog] Using MistServer through a reverse proxy

Edit on September 2020: As of version 2.18 of MistServer you no longer have to set a Public address. Setting the "X-Mst-Path" header will allow MistServer to auto-detect its proxy address.

Sometimes, it can be convenient to direct requests to MistServer through a reverse proxy, for example to limit the amount of ports that will be used or to use a prettier url.
In this blog, I'll take you through the steps to configure your web server and MistServer to work in with this. For this example I'll consider the use case of having an existing website that is running on port 80, with MistServer on the same machine, and that we want MistServer's HTTP endpoint (by default that's port 8080) to be reached through

Using a reverse proxy for MistServer does have a cost to efficiency, however.
Using this method means that instead of once, output data needs to be moved four times. Furthermore, MistServer tries to reuse connections, but it can't if they're behind a proxy server.

Configure your web server

The first step is to configure your web server to reverse proxy to MistServer's HTTP port.

For Apache:
Enable the mod_proxy and mod_proxy_http modules and add the following to your configuration file:

<Location "/mistserver/">
  ProxyPass "http://localhost:8080/"

For Nginx:
Add the following to your configuration's server block, or nested into your website's location block:

location /mistserver/ {
  proxy_pass http://localhost:8080/;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_buffering off;                      
  proxy_http_version 1.1;
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection "Upgrade";
  proxy_read_timeout 600s;
  proxy_set_header Host $host;
  proxy_set_header X-Mst-Path "$scheme://$host/mistserver";

For Lighttpd:
Add mod_proxy to your list of server modules, or add the following to your configuration file:

server.modules = ("mod_proxy")

Also, to disable response buffering, add: = 2

and for the reverse proxy itself:

$HTTP["url"] =~ "(^/mistserver/)" {
  proxy.server  = ( "" => ( "" => ( "host" => "", "port" => 8080 )))
  proxy.header = ( "map-urlpath" => ( "/mistserver/" => "/" ))

You should now be able to watch your stream directly at (MP4) or (HLS).

Configure MistServer

MistServer also outputs information about its streams, including the various urls under which the stream can be accessed. However, if reverse proxying is being used, these urls cannot be accessed externally. That can be fixed by configuring the "Public address"-setting of the HTTP protocol through the MistServer Management Interface.

You should now also be able to watch your stream at

Edit your web pages

Lastly, the urls with which streams are embedded on your webpage will need to be updated. If you are using MistServer's embed code, update any urls.

<div class="mistvideo" id="nVyzrqZSm7PJ">
    <a href="" target="_blank">
      Click here to play this video
    var a = function(){
        target: document.getElementById("nVyzrqZSm7PJ")
    if (!window.mistplayers) {
      var p = document.createElement("script");
      p.src = ""
      p.onload = a;
    else { a(); }

That's all folks! Your website should now access MistServer through the reversed proxy.

On our next blog, Erik will talk about the upcoming lock-free internal metadata structure Jaron mentioned last time.