Configure the Server¶
This guide shows you how to configure a Teyaotlani server using TOML configuration files.
Prerequisites¶
- Teyaotlani installed
- Basic familiarity with running a server (see Your First Spartan Server)
Create a configuration file¶
Create a file named config.toml with your settings:
[server]
host = "localhost"
port = 3000
document_root = "./capsule"
enable_directory_listing = true
[logging]
level = "INFO"
Load the configuration¶
Override configuration with CLI flags¶
CLI flags take precedence over configuration file values:
# Use config file but override port
teyaotlani serve --config config.toml --port 4000
# Use config file but override host
teyaotlani serve --config config.toml --host 0.0.0.0
Enable rate limiting¶
Protect your server from abuse with rate limiting:
[rate_limit]
enabled = true
capacity = 10 # Burst capacity
refill_rate = 1.0 # Tokens per second
retry_after = 30 # Suggested retry delay
This configuration allows 10 rapid requests, then throttles to 1 request per second. Rate-limited clients receive a 5 (server error) response with a suggested retry delay.
Set up access control¶
Restrict access by IP address:
[access_control]
enabled = true
allow_list = ["192.168.1.0/24", "10.0.0.0/8"]
deny_list = ["192.168.1.100/32"]
default_allow = false
Evaluation order:
- Deny list is checked first - matching IPs are blocked
- Allow list is checked second - matching IPs are allowed
- If no match,
default_allowdetermines access
Configure logging¶
Adjust logging for your needs:
[logging]
level = "DEBUG" # DEBUG, INFO, WARNING, ERROR
hash_ips = true # Privacy: hash client IPs in logs
json = false # Output JSON format for log aggregation
For production with a log aggregator:
Bind to all interfaces¶
To make your server accessible from other machines:
Security consideration
Binding to 0.0.0.0 exposes your server to the network. Consider enabling access control or using a firewall.
Verify your configuration¶
Test your configuration before deploying:
# Start with debug logging to see all settings
teyaotlani serve --config config.toml --log-level DEBUG
Check the startup logs to verify your settings are applied correctly.
Complete example¶
Here's a production-ready configuration:
[server]
host = "0.0.0.0"
port = 300
document_root = "/var/spartan/capsule"
max_file_size = 52428800 # 50 MB
enable_directory_listing = false
index_files = ["index.gmi"]
[rate_limit]
enabled = true
capacity = 20
refill_rate = 2.0
retry_after = 60
[access_control]
enabled = false # Using firewall instead
[logging]
level = "INFO"
hash_ips = true
json = true
Next steps¶
- Handle file uploads
- Configuration reference for all options