TurboCloud| | Docs| Handbook| Blog

Deploy Node.js to Hetzner in One Command with HTTPS and a Custom Domain

Start a new server on Hetzner with a public IPv4 address, Ubuntu 22.04, and SSH access from your local machine. Then, in the root folder of your project on your local machine, run the following command (replace server_public_ip with the IP of your server):

cd folder_with_project
curl https://turbocloud.dev/deploy | bash -s -- -i server_public_ip

For example, if your server’s IP address is 121.41.56.20, the command will look like this:

curl https://turbocloud.dev/deploy | bash -s -- -i 121.41.56.20

If everything goes well, your Node.js project will be deployed to Hetzner, and you’ll see an automatically generated URL in the console that you can use to access your project.

Deploying with a Custom Domain

If you want to use a custom domain, add the -d parameter (omit https://, http://, ws://, or wss://). Ensure the domain's A record is correctly pointed to your server's IP address. For example:

curl https://turbocloud.dev/deploy | bash -s -- -i server_ip4 -d your_domain.com

How Node.js Deployment to Hetzner with TurboCloud Works

TurboCloud is a deployment toolkit that automates the deployment of Node.js projects to Hetzner servers. It eliminates the need to create additional accounts and simplifies cloud provisioning by following best practices. These include protecting public projects with HTTPS, setting up VPNs for inter-server communication, establishing CI/CD pipelines, and much more.

Step-by-Step Process

  1. Set Up a Hetzner Cloud Server:

    • Create an account/login at Hetzner. Note: Hetzner checks almost all new accounts manually that's why it could take days to create a new account. If you want to start deploying now and haven't a Hetzner account - try DigitalOcean or Vultr. TurboCloud works with almost any cloud provider.
    • Navigate to Project Name -> Servers and click Add Server.
    • Choose:
      • A data center location.
      • Ubuntu 22.04 as the OS.
      • A server type
      • IPv4 enabled.
      • Your SSH key for server access.
    • Assign any name to the server.
    • Click Create and Buy Now.
    • Wait for the server to become online in the Hetzner console.

    You can deploy multiple projects on a single server using TurboCloud, as long as sufficient resources are available.

  2. How TurboCloud Deploys Node.js Projects:

    • The command above downloads the script from https://turbocloud.dev/deploy. You can manually download, inspect and execute it with the necessary parameters.
    • Once downloaded, the script is executed with your specified parameters. The only required parameter is -i, which specifies the IP address of the Hetzner server (of course, you can use other cloud providers too).
    • The project code is uploaded to the server using the scp utility.
    • The script logs into the server via SSH.
    • Required tools and services are installed on the server.
    • The script exits the server and starts a localhost tunnel to enable API requests to the TurboCloud API from your local machine. The default port used by the LocalCloud agent is 5445.
    • The TurboCloud agent checks whether the project contains a Dockerfile. If not, it uses Nixpacks to generate one.
    • A Docker image is built.
    • A new container is started.
    • The proxy server configuration is updated to forward requests from the domain to the container.
    • Old images and containers are removed if needed.

Summary

At this stage, your Node.js project should be online and accessible at the URL displayed in the console. Feel free to reach out to us if you have questions or encounter issues at hey@turbocloud.dev.