Skip to content

Instantly share code, notes, and snippets.

@NaysKutzu
Created July 31, 2023 15:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NaysKutzu/a03c492e3b8b9b7a238ec247905ae2d6 to your computer and use it in GitHub Desktop.
Save NaysKutzu/a03c492e3b8b9b7a238ec247905ae2d6 to your computer and use it in GitHub Desktop.
CodeServer Apache2 WebServer Config
<VirtualHost *:80>
ServerName <domain>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
</VirtualHost>
<VirtualHost *:443>
ServerName <domain>
ProxyPreserveHost On
# ProxyPass for regular HTTP requests
ProxyPass / http://<ip>:<port>/
ProxyPassReverse / http://<ip>:<port>/
# ProxyPass for WebSocket connections
ProxyPass /ws/ ws://<ip>:<port>/ws/
ProxyPassReverse /ws/ ws://<ip>:<port>/ws/
# Enable WebSocket support
RewriteEngine On
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /(.*) ws://<ip>:<port>/$1 [P,L]
# SSL configuration
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/<domain>/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/<domain>/privkey.pem
</VirtualHost>
@NaysKutzu
Copy link
Author

NaysKutzu commented Jul 31, 2023

Please make sure you create a ssl certificate using certbot or so and the commands to enable the modules are

sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod proxy_wstunnel
sudo service apache2 restart

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