Sites
Sites in Gruxi are defined by their domain names (hostnames). Each site can have its own configuration settings, including the document root, TLS certificates, and more.
Each site can be mapped to one or more bindings, so a single site can be served on multiple ports or IP addresses.
To default or not to default
A site can be configured as a default site, which means it will be served when no other site matches the request.
If you do not want Gruxi to respond to an unknown hostname, make sure not to mark any sites as default. In that case, Gruxi will return HTTP 404 Not Found for unknown hostnames.
How sites are matched
Gruxi uses a simple first-match algorithm to determine which site should handle a request. The first site configuration that matches the request’s hostname and port is used. If nothing matches, the default site is used (if configured).
Rewrite Functions
Gruxi supports rewrite functions that allow you to modify incoming requests before they are processed. This can be useful for URL rewriting, redirection, and other request manipulations.
Rewrite functions can be defined per site, allowing for granular control over how requests are handled.
All rewrite functions are predefined and therefore easy to add to a site.
By default, Gruxi only serves static files that exist on the filesystem.
Currently supported rewrite functions are:
OnlyWebRootIndexForSubdirs
Checks whether the request targets a file that exists. If it does, it serves the file. Otherwise, it rewrites the request to the index file in the web root (for PHP sites, typically index.php).
This rewrite rule is required for WordPress, Laravel, and similar apps to work correctly. It’s essentially needed for websites that handle their own routing (for example, WordPress routing most requests through index.php).
Site-specific HTTP headers
You can define custom HTTP headers to be included in the response for a specific site. This allows you to add security headers, caching directives, or any other headers that are relevant to your site.
These headers will be included in every response served for that site and consist of key-value pairs that you specify in the site configuration.
Next step
A big part of site configuration is defining how content should be served. Next up: processors.