How to install code-server on cloud

VSCode On Cloud

Pre-requisites:

Process:

ssh ubuntu@IPAddress
sudo apt update
sudo apt upgrade
curl -fsSL https://code-server.dev/install.sh | sh -s -- --dry-runcurl -fsSL https://code-server.dev/install.sh | sh
sudo mkdir /var/lib/code-server
sudo nano /lib/systemd/system/code-server.service
[Unit]
Description=code-server
After=nginx.service

[Service]
Type=simple
Environment=PASSWORD=code-server-password
ExecStart=/usr/bin/code-server --bind-addr 127.0.0.1:8080 --user-data-dir /var/lib/code-server --auth password
Restart=always

[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reloadsudo systemctl start code-serversudo systemctl enable code-server
sudo apt install nginx
sudo nano /etc/nginx/sites-available/code-server.conf
server {
listen 80;
listen [::]:80;
server_name code-server.example.com;
location / {
proxy_pass http://localhost:8080/;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection upgrade;
proxy_set_header Accept-Encoding gzip;
}
}
sudo rm /etc/nginx/sites-enabled/defaultsudo ln -s /etc/nginx/sites-available/code-server.conf /etc/nginx/sites-enabled/code-server.conf
sudo systemctl status nginx
sudo iptables -I INPUT 6 -m state --state NEW -p tcp --dport 80 -j ACCEPTsudo iptables -I INPUT 6 -m state --state NEW -p tcp --dport 443 -j ACCEPTsudo netfilter-persistent save
sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d code-server.example.com
sudo systemctl restart nginx
sudo nano /etc/nginx/sites-available/code-server.conf
server {
server_name code-server.example.com;
location / {
proxy_pass http://localhost:8080/;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection upgrade;
proxy_set_header Accept-Encoding gzip;
}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/code-server.example.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/code-server.example.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = code.adityacodes.online) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
listen [::]:80;
server_name code-server.example.com;
return 404; # managed by Certbot
}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store