Skip to content

Instantly share code, notes, and snippets.

@ItsOnlyBinary
Last active November 1, 2022 16:10
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ItsOnlyBinary/3e38b66d71e51d12d7df32f739978799 to your computer and use it in GitHub Desktop.
Save ItsOnlyBinary/3e38b66d71e51d12d7df32f739978799 to your computer and use it in GitHub Desktop.
<VirtualHost *:80>
ServerName kiwiirc.example.com
ServerAdmin webmaster@example.com
# Kiwi IRC client files are located here
DocumentRoot /usr/share/kiwiirc
DirectoryIndex index.html
# Reverse proxy websocket connections
# requires: a2enmod rewrite proxy proxy_wstunnel
RewriteEngine On
RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
RewriteRule .* ws://localhost:7778%{REQUEST_URI} [P,QSA,L]
# Reverse proxy http connections
# requires: a2enmod proxy proxy_http
ProxyVia On
ProxyRequests Off
ProxyPass /webirc/ http://localhost:7778/webirc/
ProxyPassReverse /webirc/ http://localhost:7778/webirc/
ProxyPreserveHost on
# send all connections to https (can remove above rewrite/proxy rules)
# RewriteCond %{SERVER_NAME} =kiwiirc.example.com
# RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
<VirtualHost *:443>
ServerName kiwiirc.example.com
ServerAdmin webmaster@example.com
# Kiwi IRC client files are located here
DocumentRoot /usr/share/kiwiirc
DirectoryIndex index.html
# SSL config
# requires: a2enmod ssl
SSLEngine on
# Reverse proxy websocket connections
# requires: a2enmod rewrite proxy proxy_wstunnel
RewriteEngine On
RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
RewriteRule .* ws://localhost:7778%{REQUEST_URI} [P,QSA,L]
# Reverse proxy http connections
# requires: a2enmod proxy proxy_http
ProxyVia On
ProxyRequests Off
ProxyPass /webirc/ http://localhost:7778/webirc/
ProxyPassReverse /webirc/ http://localhost:7778/webirc/
ProxyPreserveHost on
# Set header to allow the irc connection to be marked as secure
# requires: a2enmod headers
RequestHeader set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME}
# Letsencrypt certificates
SSLCertificateFile /etc/letsencrypt/live/kiwiirc.example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/kiwiirc.example.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment