HTTP/HTTPS Static Site Server and Reverse Proxy
FAST (File Access Speedy Transfer) is a lightweight... FAST (File Access Speedy Transfer) is a lightweight, high-performance web server designed for serving static content and acting as a reverse proxy. It prioritizes speed and efficiency, making it ideal for quickly delivering static assets and proxying requests to backend services.
- Multi-domain support
- SSL/TLS encryption
- HTTP to HTTPS redirection
- Domain-specific public directories
- Reverse proxy support
- Easy configuration via YAML
- Systemd service integration
- Minimal configuration required, allowing for quick setup and deployment
- Optimized for serving static files and proxying requests
- Optimized for serving file directories with resume on disconnect support for downloads
- High concurrency, able to handle multiple simultaneous connections efficiently
- Low memory footprint, making it suitable for various hosting environments
- Built-in caching mechanisms to further enhance performance
- Support for common web technologies like HTTP/2, SSL/TLS, and compression
FAST can be deployed in two ways:
- System Service (Traditional) - For direct system installation
- Docker Compose (Containerized) - For containerized deployment
- Go 1.16 or higher
- Make
- Systemd (for service installation)
- Root access (for installation)
-
Clone the repository:
git clone https://github.com/pollystack/fast.git cd fast-server
-
Modify the
config.yaml.example
file to suit your needs and rename it toconfig.yaml
. -
Build and install the server:
sudo make install
This will:
- Build the server for Linux
- Copy the binary to
/usr/local/bin/fast_server
- Copy the configuration to
/etc/fast/config.yaml
- Set up a systemd service
-
Start the server:
sudo systemctl start fast
The server runs as a systemd service:
- Start:
sudo systemctl start fast
- Stop:
sudo systemctl stop fast
- Restart:
sudo systemctl restart fast
- Check status:
sudo systemctl status fast
To uninstall the system service:
sudo make uninstall
- Docker
- Docker Compose
- Make (optional)
-
Initialize development environment:
make init-dev
This will:
- Create necessary directories
- Generate test SSL certificates
- Copy example configuration files
-
Start the server:
make docker-compose-up
Or directly with Docker Compose:
docker-compose up -d
The server can be configured through environment variables in .env file:
# Host Directory Paths
CONFIG_PATH=./config.yaml
SSL_PATH=./ssl
WWW_PATH=./www
LOG_PATH=./logs
# Server Ports
HTTP_PORT=80
HTTPS_PORT=443
Using Make:
- Build:
make docker-compose-build
- Start:
make docker-compose-up
- Stop:
make docker-compose-down
- View logs:
make docker-compose-logs
Using Docker Compose directly:
- Build:
docker-compose build
- Start:
docker-compose up -d
- Stop:
docker-compose down
- View logs:
docker-compose logs -f
├── config.yaml # Server configuration
├── docker-compose.yaml # Docker Compose configuration
├── .env # Environment variables
├── ssl/ # SSL certificates
│ ├── domain1.lan/
│ ├── domain2.lan/
│ └── global/
├── www/ # Web content
└── logs/ # Server logs
The server is configured via the config.yaml
file. The file location depends on your deployment method:
- System Service:
/etc/fast/config.yaml
- Docker:
./config.yaml
(mounted to/etc/fast/config.yaml
in container)
Here's an example configuration:
server:
port: 443
http_port: 80 # for HTTP to HTTPS redirect
domains:
- name: static.example.com
type: static
public_dir: /var/www/fast/static.example.com
ssl:
cert_file: /etc/fast/ssl/static.example.com/fullchain.pem
key_file: /etc/fast/ssl/static.example.com/privkey.pem
- name: files.example.com
type: file_directory
public_dir: /var/www/fast/files.example.com
ssl:
cert_file: /etc/fast/ssl/files.example.com/fullchain.pem
key_file: /etc/fast/ssl/files.example.com/privkey.pem
- name: api.example.com
type: proxy
proxy:
host: 127.0.0.1
port: 8000
ssl:
cert_file: /etc/fast/ssl/api.example.com/fullchain.pem
key_file: /etc/fast/ssl/api.example.com/privkey.pem
global_ssl:
cert_file: /etc/fast/ssl/global/fullchain.pem
key_file: /etc/fast/ssl/global/privkey.pem
log:
file: /var/log/fast/server.log
level: info # Options: debug, info, warn, error
settings:
read_timeout: 5s
write_timeout: 10s
graceful_shutdown_timeout: 30s
Domain Types
- Static Sites
(type: static)
- Serves static files from a specified directory
- Perfect for HTML, CSS, JS, and other static assets
type: static public_dir: /var/www/fast/example.com
- File Directory
(type: file_directory)
- Serves directory listings with download capabilities
- Supports resume on disconnect for large files
type: file_directory public_dir: /var/www/fast/files
- Reverse Proxy
(type: proxy)
- Forwards requests to backend services
- Supports HTTP/HTTPS backends
type: proxy proxy: host: 127.0.0.1 port: 8000
SSL certificates can be configured per domain or globally:
- Per Domain
ssl: cert_file: /etc/fast/ssl/domain.com/fullchain.pem key_file: /etc/fast/ssl/domain.com/privkey.pem
- Global Fallback
global_ssl: cert_file: /etc/fast/ssl/global/fullchain.pem key_file: /etc/fast/ssl/global/privkey.pem
Configure logging behavior:
log:
file: /var/log/fast/server.log
level: info # Options: debug, info, warn, error
Fine-tune server performance:
settings:
read_timeout: 5s
write_timeout: 10s
graceful_shutdown_timeout: 30s
- Go 1.16 or higher
- gops tool (optional, for improved debug detection)
fast-server/
├── config/
│ └── config.go # Configuration handling
├── handlers/
│ ├── handlers.go # Common handler functions
│ ├── static_handler.go # Static file handling
│ ├── proxy_handler.go # Reverse proxy handling
│ └── file_directory_handler.go # Directory listing
├── server/
│ ├── server.go # Main server implementation
│ ├── embed.go # Embedded templates
│ └── templates/ # HTML templates
├── main.go # Application entry point
└── test/ # Test files and fixtures
openssl req -x509 -newkey rsa:4096 -keyout fast-server/test/ssl/domain1.lan/privkey.pem -out fast-server/test/ssl/domain1.lan/fullchain.pem -days 365 -nodes -subj "/CN=domain1.lan"
openssl req -x509 -newkey rsa:4096 -keyout fast-server/test/ssl/domain2.lan/privkey.pem -out fast-server/test/ssl/domain2.lan/fullchain.pem -days 365 -nodes -subj "/CN=domain2.lan"
openssl req -x509 -newkey rsa:4096 -keyout fast-server/test/ssl/global/privkey.pem -out fast-server/test/ssl/global/fullchain.pem -days 365 -nodes -subj "/CN=localhost"
Install gops for runtime debugging:
go install github.com/google/gops@latest
- Create development configuration:
cp config.yaml.example config.yaml
- Set up test directories:
mkdir -p www/domain1.lan www/domain2.lan ssl/domain1.lan ssl/domain2.lan ssl/global logs
- Generate test certificates (see above)
- Build and run:
make linux ./builds/fast_server
Test different domain configurations:
- Add test domains to /etc/hosts:
127.0.0.1 domain1.lan domain2.lan
- Access test sites:
https://domain1.lan https://domain2.lan
FAST stands for:
- File
- Access
- Speedy
- Transfer
Emphasizing its core functionality of rapidly serving static files.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any problems or have any questions, please open an issue on the GitHub repository.