Repository navigation
Support passing of uvicorn specific config options to underlying runner #13
Replies: 15 comments 1 reply
|
We also need --forwarded-allow-ips=* for passing x-forwarded-for headers from a proxy in a Docker setup (from a non localhost IP). |
|
also the option to disable access logs would be useful |
|
Also would be nice to pass |
|
We need |
|
I would use a function like this to pass |
|
What about an option to invoke common ASGI servers other than uvicorn, such as hypercorn? |
|
@tiangolo Any thoughts on this thread. This will be quite useful to move completely to cli from current uvicorn command |
|
Would love to see |
|
We would love to have the |
|
I also need to pass an argument to --reload-dir and am not able using the fastapi cli, so I've ended up here. That alone would be nice, but a way to pass any arbitrary arg to the uvicorn run function would be nice. |
|
I support this request, in fact, we lose a lot of uvicorn options which are very useful when using the fastapi cli to start a server. Note The cli only uses the following options: uvicorn.run(
app=import_string,
host=host,
port=port,
reload=reload,
workers=workers,
root_path=root_path,
proxy_headers=proxy_headers,
log_config=get_uvicorn_log_config(),
)Warning While we have all this host: str = "127.0.0.1",
port: int = 8000,
uds: str | None = None,
fd: int | None = None,
loop: Literal["none", "auto", "asyncio", "uvloop"] = "auto",
http: Literal["auto", "h11", "httptools"] | Type[Protocol] = "auto",
ws: Literal["auto", "none", "websockets", "wsproto"] | Type[Protocol] = "auto",
ws_max_size: int = 16777216,
ws_max_queue: int = 32,
ws_ping_interval: float | None = 20.0,
ws_ping_timeout: float | None = 20.0,
ws_per_message_deflate: bool = True,
lifespan: Literal["auto", "on", "off"] = "auto",
interface: Literal["auto", "asgi3", "asgi2", "wsgi"] = "auto",
reload: bool = False,
reload_dirs: list[str] | str | None = None,
reload_includes: list[str] | str | None = None,
reload_excludes: list[str] | str | None = None,
reload_delay: float = 0.25,
workers: int | None = None,
env_file: str | PathLike[str] | None = None,
log_config: dict[str, Any] | str | RawConfigParser | IO | None = LOGGING_CONFIG,
log_level: str | int | None = None,
access_log: bool = True,
proxy_headers: bool = True,
server_header: bool = True,
date_header: bool = True,
forwarded_allow_ips: list[str] | str | None = None,
root_path: str = "",
limit_concurrency: int | None = None,
backlog: int = 2048,
limit_max_requests: int | None = None,
timeout_keep_alive: int = 5,
timeout_graceful_shutdown: int | None = None,
ssl_keyfile: str | PathLike[str] | None = None,
ssl_certfile: str | PathLike[str] | None = None,
ssl_keyfile_password: str | None = None,
ssl_version: int = SSL_PROTOCOL_VERSION,
ssl_cert_reqs: int = ssl. CERT_NONE,
ssl_ca_certs: str | None = None,
ssl_ciphers: str = "TLSv1",
headers: list[tuple[str, str]] | None = None,
use_colors: bool | None = None,
app_dir: str | None = None,
factory: bool = False,
h11_max_incomplete_event_size: int | None = None |
|
forwarded_allow_ips Is the most important configuration I think when running behind webserver in production, (Some of them can be set using envvar) |
|
Came here because I want to use |
|
Would love this! We need |
|
Would love this as well |
Uh oh!
There was an error while loading. Please reload this page.
First Check
Commit to Help
Example Code
Description
uvicorn cli has a lot of config options allowing some degree of customization of the server, e.g. --no-server-header (switches off server header)
fastapi cli currently doesn't support these options. This blocks moving from uvicorn to fastapi cli where such customization of server is required
If fastapi cli exposes a way to pass these options to uvicorn, it would be helpful.
Operating System
macOS
Operating System Details
macOS Sonoma Version 14.4.1
Python Version
3.12.0
Additional Context
No response
All reactions