a highly configurable webserver that uses samicpp/dotnet-http
inside appsettings.json you can specify the work and serve directory, which ports to listen to, ssl certificate, and log level.
this file needs to be in the same directory as the application or project directory.
see appsettings.default.json for the default (or fallback if not present)
and appsettings.comments.json for comments explaining each item.
appsettings.default.json
{
"h2c-address": [ "0.0.0.0:8080" ],
"09-address": [ ],
"h2-address": [ ],
"ssl-address": [ "0.0.0.0:4433" ],
"serve-dir": "./public",
"backlog": 10,
"p12-cert": "",
"p12-pass": "",
"alpn": [ "h2", "http/1.1", "http/0.9" ],
"fallback-alpn": 7112
}destination settings are inside of routes.json which need be located in the serve directory.
this file should contain a syntex similar to the following:
{
"default": {
"dir": "sub dir"
},
"query": {
"match-type": "type",
"dir": "sub dir"
},
"query2": {
"match-type": "type",
"dir": "sub dir",
"router": "file"
}
}match-typestring = "host" | "start" | "end" | "regex" | "path-start" | "scheme" | "protocol" | "domain"-
host: matches the host from the host header provided by the client
-
start: matches the start of the whole requested uri (scheme://host/path)
-
end: matches the end of the whole requested uri
-
path-start: matches only the start of the requested path
-
scheme: matches the scheme, alwayshttporhttpsunless using a non official version
-
protocol: matches the protocol used (http version), alwaysHTTP/1.1|HTTP/2(|HTTP/3planned)
-
domain: matches the domain (e.g.www.example.commatches domainexample.com)
diris used to decide the requested fileCWD/ServeDir/SubDir/Pathrouterspecifies a file to be used instead of path to calculate destination. always a file
the server will attempt to match each item starting at the top (skipping over default) and will fetch content from the sub directory starting at serve directory.
if this file isnt present it will attempt to fetch content from the serve directory directly.
if nothing was matched it will try to use the default entry. required to be present
when the file is changed the server will refresh its configuration. if the file is removed it wont remove the config
matching is case insensitive
in the same location where the destination settings are located, you can also optionally include a headers.json file.
the server will set these headers regardless of the request.
{
"Header1": "value1",
"Header2": "value2"
}besides normal files the server also supports some files that invoke custom behaviour
| file extension | description |
|---|---|
*.3xx.redirect |
redirects to the contents of the file. is a "special file" |
*.var.* |
contents get served with the correct content-type. is a "special file" |
*.link |
acts as a sort of symlink, needs to contain a absolute path or relative path to the cwd. is a "special file" |
*.dll |
loads that dll, hands it over control, and awaits it. dlls only get reimported if they change |
*.s.cs | *.s.fs | *.s.ps1 |
not yet supported. hands over control to these sippets |
*.ffi.dll | *.ffi.so |
not yet supported. loads a native library, passes it function pointers for "basic" http response and then invokes another function. |
these files get read as pieces of text and then replaces certain strings with different strings
| variable | description |
|---|---|
"%IP%" |
gets replaced by the clients remote address |
"%FULL_IP%" |
gets replaced by the clients remote address and port |
%PATH% |
gets replaced by the path |
%HOST% |
gets replaced by the host |
%SCHEME% |
gets replaced by http or https |
%BASE_DIR% |
gets replaced by the serve directory |
%USER_AGENT% |
gets replaced by the full user agent header |
%DOMAIN% |
gets replaced by an estimated guess of the domain (www.example.com -> example.com) |
- allow serving files
- support tls
- support json config files
- allow simple dynamic content files
- add file caching
- add middleware support
- make cache use compressed data & allow pre compressed files
- add script support
-
add regex file matching config files -
add protocol detectionplanned for v4.x.x