Skip to content

Commit

Permalink
Added ssl support
Browse files Browse the repository at this point in the history
  • Loading branch information
ParisNeo committed Jan 11, 2025
1 parent e21fbef commit e0e656a
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions lightrag/api/lightrag_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,16 @@ def create_app(args):
raise Exception("embedding binding not supported")



# Add SSL validation
if args.ssl:
if not args.ssl_certfile or not args.ssl_keyfile:
raise Exception("SSL certificate and key files must be provided when SSL is enabled")
if not os.path.exists(args.ssl_certfile):
raise Exception(f"SSL certificate file not found: {args.ssl_certfile}")
if not os.path.exists(args.ssl_keyfile):
raise Exception(f"SSL key file not found: {args.ssl_keyfile}")


# Setup logging
logging.basicConfig(
format="%(levelname)s:%(message)s", level=getattr(logging, args.log_level)
Expand Down Expand Up @@ -577,7 +586,17 @@ def main():
import uvicorn

app = create_app(args)
uvicorn.run(app, host=args.host, port=args.port)
uvicorn_config = {
"app": app,
"host": args.host,
"port": args.port,
}
if args.ssl:
uvicorn_config.update({
"ssl_certfile": args.ssl_certfile,
"ssl_keyfile": args.ssl_keyfile,
})
uvicorn.run(**uvicorn_config)


if __name__ == "__main__":
Expand Down

0 comments on commit e0e656a

Please sign in to comment.