Add arguments to use SSL to webserver

This commit is contained in:
javl 2022-11-18 16:33:02 +01:00 committed by blessedcoolant
parent e5951ad098
commit 87439feeb2
3 changed files with 22 additions and 3 deletions

View File

@ -215,17 +215,22 @@ class InvokeAIWebServer:
sys.exit(0) sys.exit(0)
else: else:
useSSL = (args.certfile or args.keyfile)
print(">> Started Invoke AI Web Server!") print(">> Started Invoke AI Web Server!")
if self.host == "0.0.0.0": if self.host == "0.0.0.0":
print( 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: else:
print( print(
">> Default host address now 127.0.0.1 (localhost). Use --host 0.0.0.0 to bind any address." ">> 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}") print(f">> Point your browser at http{'s' if useSSL else ''}://{self.host}:{self.port}")
self.socketio.run(app=self.app, host=self.host, port=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): def setup_app(self):
self.result_url = "outputs/" self.result_url = "outputs/"

View File

@ -303,6 +303,8 @@ The WebGUI is only rapid development. Check back regularly for updates!
| `--cors [CORS ...]` | Additional allowed origins, comma-separated | | `--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. | | `--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 | | `--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. | | `--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 ### Web Specific Features

View File

@ -615,6 +615,18 @@ class Args(object):
default='9090', default='9090',
help='Web server: Port to listen on' 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( web_server_group.add_argument(
'--gui', '--gui',
dest='gui', dest='gui',