Skip to content

Instantly share code, notes, and snippets.

@gmag11
Last active November 26, 2023 21:29
Show Gist options
  • Save gmag11/765af3682840512d8e03602614a7b24f to your computer and use it in GitHub Desktop.
Save gmag11/765af3682840512d8e03602614a7b24f to your computer and use it in GitHub Desktop.
NodeRed 1.0 reverse proxy configuration with Apache 2.4
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerName node.yourdomain.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html # this does not matter
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
SSLCertificateFile /etc/letsencrypt/live/node.yourdomain.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/node.yourdomain.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
SSLProxyEngine On
SSLProtocol TLSv1.2 -TLSv1.1
Define NodeRedURL "/nodered/" # Use your desired location
<Location ${NodeRedURL}>
RewriteEngine on
RewriteCond %{HTTP:Upgrade} ^WebSocket$ [NC]
RewriteCond %{HTTP:Connection} Upgrade$ [NC]
RewriteRule .*/(.*) "ws://localhost:1880/$1" [P,L]
ProxyPreserveHost On
ProxyRequests Off
ProxyPass http://localhost:1880/
ProxyPassReverse http://localhost:1880/
</Location>
</VirtualHost>
</IfModule>
@CornelisDenhart
Copy link

CornelisDenhart commented Nov 26, 2023

Thanks for sharing!
ProxyRequests Off resulted in ProxyRequests not allowed in <Location> context; removing this line fixed it. Apache/2.4.56 on Debian Bullseye.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment