Pluto.Configuration.ServerOptions offers the following options which can affect the link which is shown on the console:
host — must be an IP address; can be "0.0.0.0" to bind to all network interfaces on the host
port, port_hint — the former sets the port (caller needs to ensure it's free), the latter seeds the search for an open port
base_url — sets the path, typically "/"
root_url — needs to be a full URL with scheme, authority, port, and path, e.g. http://example.com:1234/
When I start Pluto on a remote server, I would like to show a link which uses a host name rather than an IP address. This is useful for a couple reasons:
Setting host="0.0.0.0" will print a URL like http://0.0.0.0:1234/open?secret=ABC123 which cannot be usefully copied to a web browser.
The user's browser/OS can decide which IP to use when resolving the host name, which could be an IPv6 address even if Pluto was started with an IPv4 address.
When I follow a Pluto link with an IP address (e.g. http://192.168.1.2/open?secret=ABC123&path=notebook.jl), Pluto immediately gave me a "No longer authenticated?" error, which I haven't experienced when using a host URL like http://myhost.local/open?secret=ABC123&path=notebook.jl
Using root_url to accomplish this is tricky because the port isn't known in advance when using port_hint, so Pluto.run(host="0.0.0.0", root_url="http://myhost.local:1234/") risks getting the URL wrong if 1234 is already in use while Pluto.run(host="0.0.0.0", root_url="http://myhost.local:1234/", port=1234) risks failing to start.
Some possible solutions: (1) add a host_name option which is used as host_str in WebServer.pretty_address or (2) replace a token like {PORT} in root_url once the port has been selected.
Pluto.Configuration.ServerOptions
offers the following options which can affect the link which is shown on the console:host
— must be an IP address; can be"0.0.0.0"
to bind to all network interfaces on the hostport
,port_hint
— the former sets the port (caller needs to ensure it's free), the latter seeds the search for an open portbase_url
— sets the path, typically"/"
root_url
— needs to be a full URL with scheme, authority, port, and path, e.g.http://example.com:1234/
When I start Pluto on a remote server, I would like to show a link which uses a host name rather than an IP address. This is useful for a couple reasons:
host="0.0.0.0"
will print a URL likehttp://0.0.0.0:1234/open?secret=ABC123
which cannot be usefully copied to a web browser.http://192.168.1.2/open?secret=ABC123&path=notebook.jl
), Pluto immediately gave me a "No longer authenticated?" error, which I haven't experienced when using a host URL likehttp://myhost.local/open?secret=ABC123&path=notebook.jl
Using
root_url
to accomplish this is tricky because the port isn't known in advance when usingport_hint
, soPluto.run(host="0.0.0.0", root_url="http://myhost.local:1234/")
risks getting the URL wrong if 1234 is already in use whilePluto.run(host="0.0.0.0", root_url="http://myhost.local:1234/", port=1234)
risks failing to start.Some possible solutions: (1) add a
host_name
option which is used ashost_str
inWebServer.pretty_address
or (2) replace a token like{PORT}
inroot_url
once the port has been selected.