Add ProxyFix middleware for Apache reverse proxy

Flask now works correctly behind Apache proxy with URL prefix.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Vadym Samoilenko 2026-03-11 21:58:41 +00:00
parent 36b12888b2
commit c7982183df

View file

@ -24,6 +24,7 @@ import threading
from datetime import datetime
from functools import wraps
from flask import Flask, jsonify, request, send_from_directory, abort, session, redirect, url_for, render_template_string
from werkzeug.middleware.proxy_fix import ProxyFix
from html_generator import (
LANGUAGE_DISPLAY_NAMES,
@ -49,6 +50,9 @@ file_lock = threading.Lock()
app = Flask(__name__, static_folder="static")
app.secret_key = os.environ.get("SECRET_KEY", "hm-ems-secret-key-change-in-production")
# Configure for running behind Apache proxy
app.wsgi_app = ProxyFix(app.wsgi_app, x_for=1, x_proto=1, x_host=1, x_prefix=1)
# Login credentials
USERNAME = "admin3_M"
PASSWORD = "Pa$$w0rd2026_!"