Work behind reverse proxy
This commit is contained in:
parent
3f77f60241
commit
080f8f6b1a
4 changed files with 17 additions and 4 deletions
|
@ -5,4 +5,10 @@ DATABASE_URL=postgres://kemal:kemal@[fc6c:b484:25b1:d25d::1]/invidious
|
|||
QUART_SECRET_KEY=0359e1c42e06fbaa284567ef7dc0faae
|
||||
|
||||
# Any Invidious instance
|
||||
ALTERNATIVE_INSTANCE_URL=https://redirect.invidious.io
|
||||
ALTERNATIVE_INSTANCE_URL=https://redirect.invidious.io
|
||||
|
||||
# The amount of reverse proxies a request from a client is proxied through
|
||||
PROXY_HOPS=0
|
||||
|
||||
# Whether to use RFC7239
|
||||
PROXY_MODERN=false
|
|
@ -68,4 +68,4 @@ ENTRYPOINT ["./entrypoint.sh"]
|
|||
|
||||
# Define the default command to run the application
|
||||
# This is passed as arguments to the entrypoint script
|
||||
CMD ["granian", "--interface", "asgi", "src.invidious_export_server:app"]
|
||||
CMD ["granian", "--host", "0.0.0.0", "--interface", "asgi", "src.invidious_export_server:fixed_app"]
|
|
@ -21,7 +21,7 @@ dependencies = [
|
|||
packages = [{include = "invidious_export_server", from = "src"}]
|
||||
|
||||
[tool.poetry.scripts]
|
||||
start = "invidious_export_server:run"
|
||||
debug = "invidious_export_server:run_debug"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core>=2.0.0,<3.0.0"]
|
||||
|
|
|
@ -2,6 +2,7 @@ from quart import Quart, redirect, request, render_template, make_response, url_
|
|||
from quart_db import QuartDB
|
||||
from quart_bcrypt import Bcrypt
|
||||
from quart_rate_limiter import RateLimiter
|
||||
from hypercorn.middleware import ProxyFixMiddleware
|
||||
|
||||
from os import environ
|
||||
from dotenv import load_dotenv
|
||||
|
@ -14,6 +15,8 @@ load_dotenv()
|
|||
app.config.from_prefixed_env()
|
||||
app.config['QUART_DB_DATABASE_URL'] = environ.get("DATABASE_URL")
|
||||
app.config['ALTERNATIVE_INSTANCE_URL'] = environ.get("ALTERNATIVE_INSTANCE_URL", "https://redirect.invidious.io")
|
||||
app.config['PROXY_MODERN'] = environ.get("PROXY_MODERN", "false").lower() == 'true'
|
||||
app.config['PROXY_HOPS'] = int(environ.get("PROXY_HOPS", 0))
|
||||
|
||||
db = QuartDB(app)
|
||||
bcrypt = Bcrypt(app)
|
||||
|
@ -21,6 +24,10 @@ rate_limiter = RateLimiter(app)
|
|||
|
||||
blueprints.register_all(app)
|
||||
|
||||
fixed_app = ProxyFixMiddleware(app,
|
||||
mode='modern' if app.config['PROXY_MODERN'] else 'legacy',
|
||||
trusted_hops=app.config['PROXY_HOPS'])
|
||||
|
||||
@app.context_processor
|
||||
def add_variables():
|
||||
return {
|
||||
|
@ -55,5 +62,5 @@ def favicon():
|
|||
def health():
|
||||
return 'OK'
|
||||
|
||||
def run() -> None:
|
||||
def run_debug() -> None:
|
||||
app.run(debug=True)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue