mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-27 11:43:54 +00:00
(feat) litellm set ssl_certificates
This commit is contained in:
parent
2280cae9a3
commit
3b57d285c2
1 changed files with 37 additions and 1 deletions
|
@ -173,6 +173,20 @@ def is_port_in_use(port):
|
||||||
is_flag=True,
|
is_flag=True,
|
||||||
help="Starts proxy via gunicorn, instead of uvicorn (better for managing multiple workers)",
|
help="Starts proxy via gunicorn, instead of uvicorn (better for managing multiple workers)",
|
||||||
)
|
)
|
||||||
|
@click.option(
|
||||||
|
"--ssl_keyfile_path",
|
||||||
|
default=None,
|
||||||
|
type=str,
|
||||||
|
help="Path to the SSL keyfile. Use this when you want to provide SSL certificate when starting proxy",
|
||||||
|
envvar="SSL_KEYFILE_PATH",
|
||||||
|
)
|
||||||
|
@click.option(
|
||||||
|
"--ssl_certfile_path",
|
||||||
|
default=None,
|
||||||
|
type=str,
|
||||||
|
help="Path to the SSL certfile. Use this when you want to provide SSL certificate when starting proxy",
|
||||||
|
envvar="SSL_CERTFILE_PATH",
|
||||||
|
)
|
||||||
@click.option("--local", is_flag=True, default=False, help="for local debugging")
|
@click.option("--local", is_flag=True, default=False, help="for local debugging")
|
||||||
def run_server(
|
def run_server(
|
||||||
host,
|
host,
|
||||||
|
@ -203,6 +217,8 @@ def run_server(
|
||||||
health,
|
health,
|
||||||
version,
|
version,
|
||||||
run_gunicorn,
|
run_gunicorn,
|
||||||
|
ssl_keyfile_path,
|
||||||
|
ssl_certfile_path,
|
||||||
):
|
):
|
||||||
global feature_telemetry
|
global feature_telemetry
|
||||||
args = locals()
|
args = locals()
|
||||||
|
@ -475,6 +491,18 @@ def run_server(
|
||||||
from litellm.proxy.proxy_server import app
|
from litellm.proxy.proxy_server import app
|
||||||
|
|
||||||
if run_gunicorn == False:
|
if run_gunicorn == False:
|
||||||
|
if ssl_certfile_path is not None and ssl_keyfile_path is not None:
|
||||||
|
print(
|
||||||
|
f"\033[1;32mLiteLLM Proxy: Using SSL with certfile: {ssl_certfile_path} and keyfile: {ssl_keyfile_path}\033[0m\n"
|
||||||
|
)
|
||||||
|
uvicorn.run(
|
||||||
|
app,
|
||||||
|
host=host,
|
||||||
|
port=port,
|
||||||
|
ssl_keyfile=ssl_keyfile_path,
|
||||||
|
ssl_certfile=ssl_certfile_path,
|
||||||
|
) # run uvicorn
|
||||||
|
else:
|
||||||
uvicorn.run(app, host=host, port=port) # run uvicorn
|
uvicorn.run(app, host=host, port=port) # run uvicorn
|
||||||
elif run_gunicorn == True:
|
elif run_gunicorn == True:
|
||||||
import gunicorn.app.base
|
import gunicorn.app.base
|
||||||
|
@ -544,6 +572,14 @@ def run_server(
|
||||||
"accesslog": "-", # Log to stdout
|
"accesslog": "-", # Log to stdout
|
||||||
"access_log_format": '%(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s',
|
"access_log_format": '%(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ssl_certfile_path is not None and ssl_keyfile_path is not None:
|
||||||
|
print(
|
||||||
|
f"\033[1;32mLiteLLM Proxy: Using SSL with certfile: {ssl_certfile_path} and keyfile: {ssl_keyfile_path}\033[0m\n"
|
||||||
|
)
|
||||||
|
gunicorn_options["certfile"] = ssl_certfile_path
|
||||||
|
gunicorn_options["keyfile"] = ssl_keyfile_path
|
||||||
|
|
||||||
StandaloneApplication(
|
StandaloneApplication(
|
||||||
app=app, options=gunicorn_options
|
app=app, options=gunicorn_options
|
||||||
).run() # Run gunicorn
|
).run() # Run gunicorn
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue