From 4b20c26e4b8e28f5f599272da1d4def2590cb94c Mon Sep 17 00:00:00 2001 From: Thomas Sileo Date: Sat, 30 Jul 2022 08:46:29 +0200 Subject: [PATCH] Better Docker support --- app/config.py | 1 + app/main.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/config.py b/app/config.py index 26b4f90..b55850e 100644 --- a/app/config.py +++ b/app/config.py @@ -41,6 +41,7 @@ class Config(pydantic.BaseModel): icon_url: str secret: str debug: bool = False + trusted_hosts: list[str] = ["127.0.0.1"] # Config items to make tests easier sqlalchemy_database: str | None = None diff --git a/app/main.py b/app/main.py index 07d0fcc..76928bf 100644 --- a/app/main.py +++ b/app/main.py @@ -76,8 +76,6 @@ _RESIZED_CACHE: MutableMapping[tuple[str, int], tuple[bytes, str, Any]] = LFUCac # TODO(ts): # # Next: -# - allow to set trusted_hosts=["*"] for Docker in config -# - maybe rename profile.toml to config.toml or add server.toml # - share nginx config in doc # - prevent double accept/double follow # - UI support for updating posts @@ -182,8 +180,10 @@ app.include_router(admin.unauthenticated_router, prefix="/admin") app.include_router(indieauth.router) app.include_router(micropub.router) app.include_router(webmentions.router) -app.add_middleware(ProxyHeadersMiddleware) + +# XXX: order matters, the proxy middleware needs to be last app.add_middleware(CustomMiddleware) +app.add_middleware(ProxyHeadersMiddleware, trusted_hosts=config.CONFIG.trusted_hosts) logger.configure(extra={"request_id": "no_req_id"}) logger.remove()