Environment: Centos
Configuration: 4h2g (tried 2h2g, no lag)
Installation#
curl -fsSL https://code-server.dev/install.sh | sh
sudo systemctl enable --now code-server@$USER
External Access#
- Install Nginx
- Open the corresponding port
- Modify the Nginx configuration file:
server {
listen 111;
server_name 222.222.222.222;
location / {
proxy_pass http://127.0.0.1:222;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
- Change 111 to the external access interface
- Change 222.222.222.222 to the server IP
- Change :222 to the code-server server internal interface
This way, you can code anywhere, on any device, without changing the environment and programming parameters due to device changes.
And all commands are executed on the server, so you don't have to worry about configuring the environment on multiple devices.