DeploymentVPS with systemd and a proxy
VPS with systemd and a proxy
Run HydroGo on any Linux server as a systemd service behind Caddy or nginx for TLS.
HydroGo is one static binary plus a config file and a data directory. On a VPS the usual shape is: hydro serve bound to localhost, managed by systemd, with Caddy or nginx terminating TLS in front.
1. Install and create the project
BASH
curl -fsSL https://github.com/hydrohq/hydrogo/releases/latest/download/install.sh | sh
sudo useradd --system --home /srv/mysite --shell /usr/sbin/nologin hydro
hydro new mysite --preset corporate --admin-email [email protected]
sudo mv mysite /srv/mysite && sudo chown -R hydro:hydro /srv/mysitehydro new refuses to write into a folder that already exists, so scaffold first and move the result into place (or build your project on your laptop and copy it).2. Production configuration
Set these in config.yaml or as HYDRO_* variables (see Environment variables):
config.yaml
profile: standard
http:
address: "127.0.0.1:8080"
public_origin: "https://cms.example.com"
behind_proxy: true
security:
secure_cookies: true
enable_hsts: trueEnrol administrators in MFA before you enable
security.mfa_required_roles.3. systemd unit
hydrogo.service
# /etc/systemd/system/hydrogo.service
[Unit]
Description=HydroGo CMS
After=network-online.target
Wants=network-online.target
[Service]
User=hydro
WorkingDirectory=/srv/mysite
EnvironmentFile=-/etc/hydrogo/env
ExecStartPre=/usr/local/bin/hydro migrate --config config.yaml
ExecStart=/usr/local/bin/hydro serve --config config.yaml
Restart=on-failure
RestartSec=3
NoNewPrivileges=true
ProtectSystem=full
ReadWritePaths=/srv/mysite
[Install]
WantedBy=multi-user.targetBASH
sudo systemctl daemon-reload
sudo systemctl enable --now hydrogo
sudo journalctl -u hydrogo -fPut secrets (DSN, keys) in
/etc/hydrogo/env with mode 0600, owned by root, instead of in the unit file or config.yaml.4. TLS proxy
cms.example.com {
encode zstd gzip
header {
Strict-Transport-Security "max-age=63072000; includeSubDomains"
X-Content-Type-Options "nosniff"
-Server
}
reverse_proxy 127.0.0.1:8080 {
header_up X-Real-IP {remote_host}
header_up X-Forwarded-Proto https
}
}The repository contains complete, hardened examples in deploy/caddy/Caddyfile and deploy/nginx/nginx.conf.
Built-in TLS
Without a proxy, HydroGo can obtain certificates itself: set http.auto_tls: true and http.domain: cms.example.com (ports 80 and 443 must be reachable). It cannot be combined with http.behind_proxy.
Verify
BASH
curl -fsS https://cms.example.com/readyz
curl -fsS https://cms.example.com/api/v1/news?locale=en\&limit=1
hydro doctor --config /srv/mysite/config.yaml