From 2f4dbb6af597281fce7677dff7b8e19cdef19767 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Jakse?= Date: Sat, 5 Sep 2020 08:47:23 +0200 Subject: [PATCH] Document configuration for Nginx --- README.md | 41 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 8e898ed..892b068 100644 --- a/README.md +++ b/README.md @@ -135,9 +135,11 @@ We will assume www-data is the UNIX user of your Web server. Adapt if necessary. exec sudo -u www-data DEBUG_LOG=true nodejs trivabble-server.js ``` -8. Configure your web server. +8. Configure your web server. In the next two sections, we describe the configuration for Apache 2 and Nginx. -On Apache 2, the relevant rules are: +#### Apache 2 + +On Apache 2, the relevant rules are: RewriteEngine on RewriteRule "^/?:trivabble/ws/(.*)" ws://localhost:3000/ws/$1 [P] @@ -153,10 +155,41 @@ a2enmod proxy_wstunnel a2enmod rewrite ``` -A full example is available in (doc/trivabble-apache-host.conf.sample)[doc/trivabble-apache-host.conf.sample]. - :warning: Be careful to allow enough concurrent processes / threads / workers on your web server. Each player requires one long-standing connection (XHR, SSE or WebSocket), plus small requests when not using WebSockets. +Long-standing connections may cause issues with Apache 2, and using HTTP 2 may lead to "interesting" behavior. + +### Nginx + +Here is an example of an Nginx configuration for Trivabble: + +``` +server { + listen 443 ssl http2; + listen [::]:443 ssl http2; + + server_name trivabble.example.org; + + location /:trivabble/ws/ { + proxy_pass http://127.0.0.1:3000; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "Upgrade"; + proxy_set_header Host $host; + } + + location /:trivabble { + proxy_pass http://127.0.0.1:3000; + proxy_buffering off; + } + + location /trivabble { + alias /var/www/html/trivabble-public; + } + + # SSL configuration here +} +``` ## Enable the spell checker -- 2.30.2