Add a site
Protect a website or API with HostWall from the dashboard, the CLI or the config file, and check that it works.
A site is one website or API that HostWall protects. It has a domain (plus optional aliases such as www.), and an upstream: the address where your app listens.
Before you start
- Point the domain's DNS at the HostWall server (an
Arecord, andAAAAfor IPv6). Check withdig +short example.com. - Make sure HostWall can reach your app, for example
curl -i http://localhost:3000on the server.
In the dashboard
Right after your first sign-in, HostWall shows Protect your first site. Later, use Sites → Add site.
- Domain: the address visitors use, such as
shop.example.com. Add more hostnames under Aliases, comma separated. - App address: where your app listens, such as
localhost:3000orhttp://10.0.0.5:8080. - Check the connection. HostWall looks up the domain and tries to reach your app, and tells you what it finds.
- Choose protection: keep Monitor to start. It logs attacks without blocking anything.
- Optional Advanced settings: HTTPS, security headers, paranoia level and what happens if inspection fails. The defaults are right for most sites.
- Click Protect site (or Add site).
Changes apply immediately, without a restart. HostWall requests a certificate in the background; the Sites page shows its status.
With the CLI
sudo hostwall site add example.com --upstream localhost:3000 --alias www.example.comNew sites use defaults.mode (monitor) unless you pass --mode. See hostwall site.
In the config file
Add the site to /etc/hostwall/hostwall.yaml:
sites:
- domain: example.com
aliases: [www.example.com]
upstream: http://localhost:3000HostWall reloads the file within about 2 seconds. In the dashboard you can change a file site's mode and protection settings (stored on top of the file, with a reset); its domain, aliases, app address and HTTPS stay in the file. See File sites and dashboard sites.
Check that it works
-
Open
https://example.com. Plainhttp://redirects tohttps://once the certificate is ready, usually within a minute. -
Send a harmless test attack from your computer:
curl -s -o /dev/null -w "%{http_code}\n" "https://example.com/?id=1%27%20OR%20%271%27%3D%271"In monitor mode you get your app's normal status (usually
200), and the request appears on the Attacks page as Would block. -
Make sure visitors can't skip HostWall: your app should listen on
127.0.0.1only, or have its port firewalled.
Next: Monitor vs block mode.
Common upstreams
| Your app runs | Upstream |
|---|---|
| On the same server | localhost:3000 |
| On another server in your network | http://10.0.0.5:8080 |
| In Docker, next to HostWall's container | http://app:3000 (the service name) |
| On the Docker host, with HostWall in a container | http://host.docker.internal:3000 |
| Behind HTTPS with a valid certificate | https://app.internal |
| On several servers | a list; requests are spread round-robin |