Better Docker support

This commit is contained in:
Thomas Sileo 2022-07-30 08:46:29 +02:00
parent 7469188aaf
commit 4b20c26e4b
2 changed files with 4 additions and 3 deletions

View file

@ -41,6 +41,7 @@ class Config(pydantic.BaseModel):
icon_url: str icon_url: str
secret: str secret: str
debug: bool = False debug: bool = False
trusted_hosts: list[str] = ["127.0.0.1"]
# Config items to make tests easier # Config items to make tests easier
sqlalchemy_database: str | None = None sqlalchemy_database: str | None = None

View file

@ -76,8 +76,6 @@ _RESIZED_CACHE: MutableMapping[tuple[str, int], tuple[bytes, str, Any]] = LFUCac
# TODO(ts): # TODO(ts):
# #
# Next: # 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 # - share nginx config in doc
# - prevent double accept/double follow # - prevent double accept/double follow
# - UI support for updating posts # - 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(indieauth.router)
app.include_router(micropub.router) app.include_router(micropub.router)
app.include_router(webmentions.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(CustomMiddleware)
app.add_middleware(ProxyHeadersMiddleware, trusted_hosts=config.CONFIG.trusted_hosts)
logger.configure(extra={"request_id": "no_req_id"}) logger.configure(extra={"request_id": "no_req_id"})
logger.remove() logger.remove()