Proxy application intended for usage with cold start servers
4.1K

An intelligent PHP-based proxy server for routing, static file serving, and middleware—fully configurable via PHP files.
Project repository: https://github.com/darthjee/tent
To run a proxy server using this image:
services:
tent:
image: darthjee/tent:latest
ports:
- "8080:80"
volumes:
- ./your-config:/var/www/html/configuration/ # REQUIRED: your PHP configuration files
- ./your-static:/var/www/html/static/ # OPTIONAL: static files (if your config uses static/fixed handlers)
env_file:
- .env # OPTIONAL: environment variables
configuration/ folder in your host machine.configure.php and rule files (rules/backend.php, rules/frontend.php)./var/www/html/configuration/.http://localhost:8080 (or your mapped port).Example test command:
curl http://localhost:8080/persons
Configuration is done via PHP files placed in /var/www/html/configuration/. Each file can define one or more rules using the Tent\\Configuration::buildRule method. Example files:
configure.php: Main entry, includes other rule files.rules/frontend.php: Rules for frontend/static/proxy handling.rules/backend.php: Rules for backend proxying.<?php
require_once __DIR__ . '/rules/frontend.php';
require_once __DIR__ . '/rules/backend.php';
<?php
use Tent\Configuration;
Configuration::buildRule([
'handler' => [
'type' => 'default_proxy',
'host' => 'http://api.com:80'
],
'matchers' => [
['method' => 'GET', 'uri' => '/api/', 'type' => 'begins_with']
]
]);
default_proxy is the recommended default for proxying. Use 'type' => 'proxy' only when you need a fully custom middleware stack.
<?php
use Tent\Configuration;
if (getenv('FRONTEND_DEV_MODE') === 'true') {
Configuration::buildRule([
'handler' => [
'type' => 'proxy', // custom proxy setup for Vite dev server
'host' => 'http://frontend:8080'
],
'matchers' => [
['method' => 'GET', 'uri' => '/', 'type' => 'exact'],
],
'middlewares' => [
[
'class' => 'Tent\Middlewares\SetHeadersMiddleware',
'headers' => ['Host' => 'frontend.local']
]
]
]);
} else {
Configuration::buildRule([
'handler' => [
'type' => 'static',
'location' => '/var/www/html/static'
],
'matchers' => [
['method' => 'GET', 'uri' => '/', 'type' => 'exact'],
],
'middlewares' => [
[
'class' => 'Tent\Middlewares\SetPathMiddleware',
'path' => '/index.html'
]
]
]);
}
FRONTEND_DEV_MODE in the example above is development-specific (from this repository's dev setup).
For production usage of the Docker image, this variable is usually not required. You can define your own rules in configuration/ without using FRONTEND_DEV_MODE.
If you do use the same dev/prod split pattern:
FRONTEND_DEV_MODE=true: proxies frontend requests to a frontend dev server (example above uses http://frontend:8080).FRONTEND_DEV_MODE=false: serves frontend files from /var/www/html/static using static rules.8080:80).services:
tent:
image: darthjee/tent:latest
ports:
- "8080:80"
volumes:
- ./docker_volumes/configuration:/var/www/html/configuration/
- ./dev/frontend/dist:/var/www/html/static/
env_file:
- .env
Tent uses Apache with PHP to process all incoming requests through a centralized entry point:
.htaccess rewrites all requests to index.phpClient Request
↓
Apache (.htaccess rewrite)
↓
index.php
↓
RequestProcessor
↓
┌─────────────────────────────┐
│ Middleware Chain │
│ ┌─────────────────────────┐ │
│ │ FileCacheMiddleware │ │
│ │ SetHeadersMiddleware │ │
│ │ CacheMiddleware │ │
│ │ ... │ │
│ └─────────────────────────┘ │
└─────────────────────────────┘
↓
Handler Selection
┌────────────┬───────────────┬─────────────┐
↓ ↓ ↓
Proxy StaticFile Error
Handler Handler Handler
┌─────────────┐
↓ ↓
404 Not Found 403 Forbidden
Tent includes a flexible middleware system for request/response processing. Built-in middlewares include:
Middlewares are specified in configuration rules and executed in order. See configuration examples below.
Content type
Image
Digest
sha256:59acecda8…
Size
193.2 MB
Last updated
about 1 month ago
docker pull darthjee/tent