Skip to content

Commit 3a8ee91

Browse files
challgrenclaude
andcommitted
Add reverse proxy support for Flask application
- Added ProxyFix middleware to handle X-Forwarded-* headers - Configured proper trust levels for proxy headers (For, Proto, Host, Prefix) - Application now works correctly behind docker-reversewebproxy - Added documentation for reverse proxy configuration - All API endpoints use relative URLs for proxy compatibility 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent fff95e0 commit 3a8ee91

2 files changed

Lines changed: 39 additions & 0 deletions

File tree

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,33 @@ Access at: `http://localhost:8888`
127127
Access at: `http://localhost:8888/history`
128128

129129
- Browse all historical pattern detections
130+
131+
### Reverse Proxy Support
132+
133+
The application works seamlessly behind reverse proxies like `ghcr.io/sdr-enthusiasts/docker-reversewebproxy`. The Flask application automatically handles:
134+
135+
- `X-Forwarded-For` - Client IP addresses
136+
- `X-Forwarded-Proto` - HTTP/HTTPS protocol
137+
- `X-Forwarded-Host` - Original hostname
138+
- `X-Forwarded-Prefix` - URL path prefix
139+
140+
Example reverse proxy configuration:
141+
142+
```yaml
143+
services:
144+
reversewebproxy:
145+
image: ghcr.io/sdr-enthusiasts/docker-reversewebproxy:latest
146+
ports:
147+
- "80:80"
148+
- "443:443"
149+
environment:
150+
- PROXY_HOSTS=aircraft,aircraft-circle,8888
151+
152+
aircraft-circle:
153+
image: ghcr.io/challgren/aircraft-circle:latest
154+
environment:
155+
- TAR1090_URL=http://tar1090:80
156+
```
130157
- Filter by date range, pattern type, and callsign
131158
- Visual timeline of detection activity
132159
- Direct links to TAR1090 replay for each pattern

app.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,6 +1380,7 @@
13801380
import shutil
13811381
from flask import Flask, render_template_string, jsonify
13821382
from flask_cors import CORS
1383+
from werkzeug.middleware.proxy_fix import ProxyFix
13831384
import webbrowser
13841385

13851386

@@ -2510,6 +2511,17 @@ def start_web_server(self, port=8888):
25102511
static_folder = None
25112512

25122513
app = Flask(__name__, static_folder=static_folder)
2514+
2515+
# Configure for reverse proxy - handles X-Forwarded-* headers
2516+
# This allows the app to work correctly behind docker-reversewebproxy
2517+
app.wsgi_app = ProxyFix(
2518+
app.wsgi_app,
2519+
x_for=1, # Trust X-Forwarded-For header for client IP
2520+
x_proto=1, # Trust X-Forwarded-Proto for HTTP/HTTPS
2521+
x_host=1, # Trust X-Forwarded-Host for original host
2522+
x_prefix=1 # Trust X-Forwarded-Prefix for URL prefix
2523+
)
2524+
25132525
CORS(app)
25142526
self.web_app = app
25152527

0 commit comments

Comments
 (0)