Created
July 31, 2023 15:21
-
-
Save NaysKutzu/a03c492e3b8b9b7a238ec247905ae2d6 to your computer and use it in GitHub Desktop.
CodeServer Apache2 WebServer Config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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