diff --git a/backend/invoke_ai_web_server.py b/backend/invoke_ai_web_server.py index 07e76e9263..86fda19f2e 100644 --- a/backend/invoke_ai_web_server.py +++ b/backend/invoke_ai_web_server.py @@ -215,17 +215,22 @@ class InvokeAIWebServer: sys.exit(0) else: + useSSL = (args.certfile or args.keyfile) print(">> Started Invoke AI Web Server!") if self.host == "0.0.0.0": print( - f"Point your browser at http://localhost:{self.port} or use the host's DNS name or IP address." + f"Point your browser at http{'s' if useSSL else ''}://localhost:{self.port} or use the host's DNS name or IP address." ) else: print( ">> Default host address now 127.0.0.1 (localhost). Use --host 0.0.0.0 to bind any address." ) - print(f">> Point your browser at http://{self.host}:{self.port}") - self.socketio.run(app=self.app, host=self.host, port=self.port) + print(f">> Point your browser at http{'s' if useSSL else ''}://{self.host}:{self.port}") + if not useSSL: + self.socketio.run(app=self.app, host=self.host, port=self.port) + else: + self.socketio.run(app=self.app, host=self.host, port=self.port, + certfile=args.certfile, keyfile=args.keyfile) def setup_app(self): self.result_url = "outputs/" diff --git a/docs/features/WEB.md b/docs/features/WEB.md index 795d9cf962..c6f4d3d387 100644 --- a/docs/features/WEB.md +++ b/docs/features/WEB.md @@ -303,6 +303,8 @@ The WebGUI is only rapid development. Check back regularly for updates! | `--cors [CORS ...]` | Additional allowed origins, comma-separated | | `--host HOST` | Web server: Host or IP to listen on. Set to 0.0.0.0 to accept traffic from other devices on your network. | | `--port PORT` | Web server: Port to listen on | +| `--certfile CERTFILE` | Web server: Path to certificate file to use for SSL. Use together with --keyfile | +| `--keyfile KEYFILE` | Web server: Path to private key file to use for SSL. Use together with --certfile' | | `--gui` | Start InvokeAI GUI - This is the "desktop mode" version of the web app. It uses Flask to create a desktop app experience of the webserver. | ### Web Specific Features diff --git a/ldm/invoke/args.py b/ldm/invoke/args.py index e626b4206f..5d60153a60 100644 --- a/ldm/invoke/args.py +++ b/ldm/invoke/args.py @@ -615,6 +615,18 @@ class Args(object): default='9090', help='Web server: Port to listen on' ) + web_server_group.add_argument( + '--certfile', + type=str, + default=None, + help='Web server: Path to certificate file to use for SSL. Use together with --keyfile' + ) + web_server_group.add_argument( + '--keyfile', + type=str, + default=None, + help='Web server: Path to private key file to use for SSL. Use together with --certfile' + ) web_server_group.add_argument( '--gui', dest='gui',