Configure app for Nginx Proxy Manager reverse proxy. Add ProxyFix middleware to Flask and X-Forwarded-Host header to nginx config for proper proxy header handling.
This commit is contained in:
parent
841110faca
commit
329e22cfd6
4
app.py
4
app.py
|
|
@ -2,6 +2,7 @@ import os
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from flask import Flask, render_template, request, redirect, url_for, flash, jsonify
|
from flask import Flask, render_template, request, redirect, url_for, flash, jsonify
|
||||||
from slugify import slugify
|
from slugify import slugify
|
||||||
|
from werkzeug.middleware.proxy_fix import ProxyFix
|
||||||
|
|
||||||
from config import config
|
from config import config
|
||||||
from models import db, User, BlogPost, ForumCategory, ForumTopic, ForumReply, ContactMessage
|
from models import db, User, BlogPost, ForumCategory, ForumTopic, ForumReply, ContactMessage
|
||||||
|
|
@ -14,6 +15,9 @@ def create_app(config_name=None):
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.config.from_object(config[config_name])
|
app.config.from_object(config[config_name])
|
||||||
|
|
||||||
|
# Trust proxy headers from Nginx Proxy Manager → local nginx (2 proxies)
|
||||||
|
app.wsgi_app = ProxyFix(app.wsgi_app, x_for=2, x_proto=1, x_host=1, x_prefix=1)
|
||||||
|
|
||||||
db.init_app(app)
|
db.init_app(app)
|
||||||
|
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ server {
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
proxy_set_header X-Forwarded-Host $host;
|
||||||
proxy_connect_timeout 300s;
|
proxy_connect_timeout 300s;
|
||||||
proxy_read_timeout 300s;
|
proxy_read_timeout 300s;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -873,6 +873,10 @@ video {
|
||||||
height: 4rem;
|
height: 4rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.h-20 {
|
||||||
|
height: 5rem;
|
||||||
|
}
|
||||||
|
|
||||||
.h-24 {
|
.h-24 {
|
||||||
height: 6rem;
|
height: 6rem;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue