Skip to content

Commit

Permalink
Added the ability to disable port from being added so that users that…
Browse files Browse the repository at this point in the history
… have server redirects via nginx can use it
  • Loading branch information
trpipher committed Feb 1, 2024
1 parent ac6ec6a commit 3ffdf5b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib_comfyui/webui/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ def create_section():
shared.opts.onchange("comfyui_reverse_proxy_enabled", update_reverse_proxy_enabled)
update_reverse_proxy_enabled()

shared.opts.add_option("comfyui_reverse_proxy_disable_port", shared.OptionInfo(False,'Disable using the port when using reverse_proxy. Useful if using a nginx server',section=section))


@ipc.restrict_to_process('webui')
def update_enabled():
Expand Down Expand Up @@ -161,7 +163,7 @@ def get_comfyui_client_url():

def canonicalize_url(input_url: str, default_port: int = 8189) -> str:
from urllib.parse import urlparse, urlunparse

from modules import shared
# Step 1: Prepend 'http://' if scheme is missing
if not input_url.startswith(('http://', 'https://')):
input_url = 'http://' + input_url
Expand All @@ -173,8 +175,9 @@ def canonicalize_url(input_url: str, default_port: int = 8189) -> str:
scheme = parsed.scheme if parsed.scheme else 'http'

# Step 4: Add the missing port
disable_port = shared.opts.data.get('comfyui_reverse_proxy_disable_port',False)
netloc = parsed.netloc
if ':' not in netloc: # Check if port is missing
if ':' not in netloc and not disable_port: # Check if port is missing
netloc += f":{default_port}"
elif netloc.count(':') == 1 and parsed.scheme: # If port exists but scheme was present in input
host, port = netloc.split(':')
Expand Down

0 comments on commit 3ffdf5b

Please sign in to comment.