Skip to content

Instantly share code, notes, and snippets.

@amitkhare
Last active March 14, 2024 17:45
Show Gist options
  • Save amitkhare/a7867b9a3e25338803549901ea4bf3d8 to your computer and use it in GitHub Desktop.
Save amitkhare/a7867b9a3e25338803549901ea4bf3d8 to your computer and use it in GitHub Desktop.
Code-Server behind Apache2 Proxy with Letsencrypt SSL
#Located in :::: /lib/systemd/system/code-server.service
[Unit]
Description=code-server
After=network.target
[Service]
Type=simple
ExecStartPre=/bin/sleep 2
User=1000
Group=1000
#start
ExecStart=/vsc-data/binary/bin/code-server --config /vsc-data/config.yaml
#stop
#ExecStop=
Restart=always
[Install]
WantedBy=default.target
<VirtualHost *:443>
ServerName code.example.com
RewriteEngine On
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /(.*) wss://127.0.0.1:8443/$1 [P,L]
SSLProxyEngine on
ProxyPreserveHost on
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
ProxyPass / https://127.0.0.1:8443/
ProxyPassReverse / https://127.0.0.1:8443/
SSLCertificateFile /etc/letsencrypt/live/code.example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/code.example.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
#Located in :::: nano ~/.config/code-server/config.yaml
bind-addr: 0.0.0.0:8443
auth: password
password: YOURPASSWORD
user-data-dir: /vsc-data/user-data
extensions-dir: /vsc-data/extensions-dir
app-name: "Khare's Code"
cert: true
@amitkhare
Copy link
Author

$ systemctl daemon-reload
$ systemctl start code-server
$ systemctl enable code-server
$ systemctl status code-server

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