]> git.immae.eu Git - perso/Immae/Config/Nix.git/commitdiff
Fix peertube websockets
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Fri, 10 May 2019 23:48:52 +0000 (01:48 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Fri, 10 May 2019 23:48:52 +0000 (01:48 +0200)
nixops/modules/websites/tools/peertube.nix

index ab5e08a18c27f8517e7e8de0b67e36059bc3f6f8..a9f06cca47699b517b73ab0aa24ec8d0cd9a78ed 100644 (file)
@@ -159,17 +159,20 @@ in {
       hosts       = [ "peertube.immae.eu" ];
       root        = null;
       extraConfig = [ ''
+          RewriteEngine On
+
+          RewriteCond %{REQUEST_URI}  ^/socket.io            [NC]
+          RewriteCond %{QUERY_STRING} transport=websocket    [NC]
+          RewriteRule /(.*)           ws://localhost:${env.listenPort}/$1 [P,NE,QSA,L]
+
+          RewriteCond %{REQUEST_URI}  ^/tracker/socket       [NC]
+          RewriteRule /(.*)           ws://localhost:${env.listenPort}/$1 [P,NE,QSA,L]
+
           ProxyPass /        http://localhost:${env.listenPort}/
           ProxyPassReverse / http://localhost:${env.listenPort}/
 
           ProxyPreserveHost On
           RequestHeader set X-Real-IP %{REMOTE_ADDR}s
-
-          ProxyPass /tracker/socket        ws://127.0.0.1:${env.listenPort}/tracker/socket
-          ProxyPassReverse /tracker/socket ws://127.0.0.1:${env.listenPort}/tracker/socket
-
-          ProxyPass /socket.io        ws://127.0.0.1:${env.listenPort}/socket.io
-          ProxyPassReverse /socket.io ws://127.0.0.1:${env.listenPort}/socket.io
       '' ];
     };
   };