An efficient web server with file synchronization via LFTP and MaxMind geo-blocking support.
1.4K
PHP-LFTP Geo-Blocking Docker Image (Optimized Trixie Builds)
This Docker image provides a efficient web server based on PHP 8.4/8.5 with Apache, designed to serve PHP applications while supporting secure file synchronization via lftp. It comes pre-configured with commonly used PHP extensions and allows PHP scripts to execute lftp commands via sudo for fetching files over FTP, FTPS, or SFTP.
✅ Features
Base Image: Built on the official PHP 8.4/8.5 Trixie image with Apache support, ensuring stability and compatibility for modern PHP applications.
Pre-installed PHP Extensions: Includes essential extensions for most web applications:
File Synchronization with lftp:
Apache Configuration:
Production-ready PHP:
🚀 Getting Started
Pull the image from Docker Hub:
Run the PHP 8.4 container:
docker run -d --name webserver -p 80:80 chrno79/php-lftp-gb:latest
This will start Apache on port 80.
📁 Volume Mapping
To serve your PHP files:
docker run -d --name webserver -p 80:80 \
-v /path/to/your/php/files:/var/www/html \
chrno79/php-lftp-gb:latest
Replace /path/to/your/php/files with the path to your PHP application.
🔧 Using RemoteIP
To forward the real client IP from a reverse proxy, mount your remoteip.conf:
RemoteIPHeader X-Forwarded-For
RemoteIPTrustedProxy 172.18.0.0/16 <-- Webspace Network
RemoteIPTrustedProxy 172.19.0.0/24 <-- Reverse Proxy Network
Mount it:
docker run -d --name webserver -p 80:80 \
-v /path/to/remoteip.conf:/etc/apache2/conf-enabled/remoteip.conf:ro \
-v /path/to/your/php/files:/var/www/html \
chrno79/php-lftp:latest
The container automatically enables the config at startup.
Nginx-Proxy-Manager:
Edit Proxy Host -> Advanced -> Custom Nginx Configuration:
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host;
🔧 Mount with custom php.ini:
You can provide your own PHP configuration:
docker run -d --name webserver -p 80:80 \
-v /path/to/remoteip.conf:/etc/apache2/conf-enabled/remoteip.conf:ro \
-v /path/to/your/php/files:/var/www/html \
-v /path/to/your/custom_php.ini:/usr/local/etc/php/php.ini
chrno79/php-lftp-gb:latest
⛔️ Geo-blocking via .htaccess
.htaccess (Minimum version)
########################################
# 0. Optional: ALLOW OWN IP ADDRESSES (RECOMMENDED)
########################################
# Require ip 192.168.100.0/24
########################################
# 1. SECURITY HEADERS
########################################
<IfModule mod_headers.c>
Header always unset X-Frame-Options
Header always set Content-Security-Policy "frame-ancestors 'self'; base-uri 'self'; form-action 'self';"
Header always set X-Content-Type-Options "nosniff"
Header always set Referrer Policy "strict-origin-when-cross-origin"
Header always set X-XSS-Protection "1; mode=block"
# HSTS (only if HTTPS!)
Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"
</IfModule>
########################################
# 2. REWRITE ENGINE ON
########################################
RewriteEngine On
########################################
# 3. GEO BLOCK (DACH + LU only)
########################################
#SetEnvIf MM_COUNTRY_CODE ^(DE|AT|CH|LU)$ AllowCountry
#<RequireAll>
# Require env AllowCountry
#</RequireAll>
########################################
# 4. BLOCK DIRECT IP ACCESS
########################################
RewriteCond %{HTTP_HOST} ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$
RewriteRule ^ - [F,L]
##########################################
# 5. BLOCK EMPTY USER AGENTS
##########################################
RewriteCond %{HTTP_USER_AGENT} ^$
RewriteRule ^ - [F,L]
########################################
# 6. ALLOW ONLY GENUINE BROWSER
########################################
RewriteCond %{HTTP_USER_AGENT} !(Mozilla|Firefox|Chrome|Safari|Edg|Opera) [NC]
RewriteRule ^ - [F,L]
########################################
# 7. BLOCK SCRAPERS / SCANNERS
##########################################
RewriteCond %{HTTP_USER_AGENT} (bot|crawl|spider|scanner|scraper|curl|wget|python|libwww|httpclient|okhttp|java|perl|nikto|sqlmap|nmap|masscan) [NC]
RewriteRule ^ - [F,L]
########################################
# 8. BLOCK AI BOTS
########################################
RewriteCond %{HTTP_USER_AGENT} (GPTBot|ChatGPT|ClaudeBot|CCBot|Bytespider|Amazonbot|PerplexityBot|YouBot|Meta-ExternalAgent|Meta-ExternalFetcher) [NC]
RewriteRule ^ - [F,L]
########################################
# 9. BLOCK DANGEROUS HTTP METHODS
##########################################
RewriteCond %{REQUEST_METHOD} ^(TRACE|DELETE|TRACK|DEBUG|CONNECT) [NC]
RewriteRule ^ - [F,L]
########################################
# 10. BLOCK HIDDEN FILES
########################################
RewriteRule /\.(git|env|htaccess|htpasswd) - [F,L]
########################################
# 11. BLOCK SENSITIVE FILE TYPES
########################################
<FilesMatch "\.(log|sql|env|ini|bak|old|conf|yml|yaml|txt|json)$">
Require all denied
</FilesMatch>
########################################
# 12. BLOCK HIDDEN FILES
########################################
<FilesMatch "^\.">
Require all denied
</FilesMatch>
########################################
# 13. DISABLE DIRECTORY VIEW
########################################
Options -Indexes
########################################
# 14. Prevent browser caching
########################################
<IfModule mod_headers.c>
<FilesMatch "\.(js|css|html|php)$">
Header set Cache-Control "no-cache, must-revalidate"
</FilesMatch>
</IfModule>
🤝 Contributing
Contributions are welcome! Fork the repository and submit pull requests for improvements, new features, or updated extensions.
Content type
Image
Digest
sha256:02d050320…
Size
423.2 MB
Last updated
about 2 months ago
docker pull chrno79/php-lftp-gb