Skip to content

virtual host

User65k edited this page Oct 10, 2021 · 3 revisions

A virtual host is used to name the server. A catch all entry can handle all requests to names not mentioned in the config file.

However, multiple vHosts can listen on the same socket if validate_server_name is set (for all or all but one).

A single vHost contains one or multiple mount paths. At least one vHost is required.

Config

Every key not taken in the Server Config will be a vHost (if it has at least the subkey ip)

key meaning
ip Socket to bind on, e.g. 127.0.0.1:8080
validate_server_name Optional Make sure the Host-Header matches the name of this Host. Warning: A vHost it not a security feature.
tls Optional Use TLS
anything else mount path

Note that a mount on / can be specified by directly using the keys of a mount path. If you want to mount on a keyword (like /ip) prefix it with grave accent "`". If you want to mount on something beginning with grave accent use two.

Example

# Define two Hosts on Port 80
["example.com"]
ip = "127.0.0.1:80"
# This Host will also be used if the Client uses the IP-Address or something else as Host

["api.example.com"]
ip = "127.0.0.1:80"
validate_server_name = true # This Host is only used if requested by the client

# Define a single Host on Port 8080
[internal]
ip = "127.0.0.1:8080"
# This Host will be served to all clients connecting to this Port

[my_hidden_but_not_secure_host]
ip = "127.0.0.1:7001"
validate_server_name = true # This Host is only used if requested by the client
# all other requests will get 403 Permission Denied

Clone this wiki locally