Remote Development Environment#
Prerequisites#
Don't want to spend money on a server, but have idle devices at home, like NAS, etc.
Required Content#
A server, a free domain name, Cloudflare account
Operations#
Install SSH on your server and enable it.
Host the domain on Cloudflare.
Click on Zero Trust on the left side of Cloudflare.
Click on Tunnels under Network.
Then click on Create Tunnel to create a tunnel.
Click the three dots on the right side and select Configure.
Then go back to the server and choose to install based on your server system.
Then click on the Public Hostname above.
Click Add Public Hostname, name the subdomain as you like, the domain at the back should be the one bound when creating the tunnel, select SSH for the type, and I tested that filling in localhost for the URL works fine.
After setting up, open your local VSCode, search for SSH in the extensions, and install Remote-SSH.
After installation, an icon will appear next to it, click it.
Then click the settings button next to SSH.
Just select the first option.
Fill in the domain name you just set, the user is the login user, I am using key-based login here, so there will be a file path for IdentityFile; if not, delete this line and use password login.
After saving, a host will appear next to it.
The arrow connects in the current window, while the one behind opens in a new window.
But it cannot connect now because it uses Cloudflared for internal network penetration, so you need to install the Cloudflared client on your local machine.
Visit https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/downloads/
Choose to install based on your operating system.
After installation, click Connect and wait a moment.
Choose a folder where you created your project, and create a project directly.
My server's development environment is already set up, so I can create it directly.
Later, if you switch devices for development, you only need to install the Cloudflared client and the Remote-SSH plugin on VSCode, without repeatedly installing Node.js and node_modules, as node_modules is like pulling a large chunk onto your computer.