Skip to content

Use container hostname + manager base URL instead of hardcoded IP in VS Code and SSH links#242

Closed
Copilot wants to merge 3 commits intomainfrom
copilot/fix-hardcoded-ip-addresses
Closed

Use container hostname + manager base URL instead of hardcoded IP in VS Code and SSH links#242
Copilot wants to merge 3 commits intomainfrom
copilot/fix-hardcoded-ip-addresses

Conversation

Copy link
Contributor

Copilot AI commented Mar 15, 2026

SSH links on the containers page used site.externalIp as the host, producing raw-IP URLs (ssh://user@1.2.3.4:2222) that pollute VS Code and iTerm2 connection history with meaningless addresses.

Image

Changes

  • routers/containers.js — Derives baseUrl by stripping the first subdomain from req.hostname (e.g. manager.os.mieweb.orgos.mieweb.org), then computes sshHost = {container.hostname}.{baseUrl} per row. sshHost is included in the row payload for both API and view responses.
  • views/containers/index.ejs — Replaces site.externalIp with r.sshHost in the vscode:// and ssh:// link hrefs; updates the render guard from site.externalIp to r.sshHost.

Result

# Before
vscode://vscode-remote/ssh-remote+alice@203.0.113.5:2222/
ssh://alice@203.0.113.5:2222

# After
vscode://vscode-remote/ssh-remote+alice@mycontainer.os.mieweb.org:2222/
ssh://alice@mycontainer.os.mieweb.org:2222

The links now render as {container}.{base_url}:{port}, giving meaningful names in connection history without requiring any additional configuration.

Original prompt

This section details on the original issue you should resolve

<issue_title>[Bug]: "Open in VS Code" and "Open SSH in terminal" use hardcoded IP addresses</issue_title>
<issue_description>### Current URL

https://manager.os.mieweb.org/sites/1/containers

Username

No response

Version

No response

Steps to reproduce

when on the https://manager.os.mieweb.org/sites/1/containers route, the links for "Open in VS Code" and "Open SSH in terminal" use hardcoded IP addresses.

This causes history to show unintuitive history when looking at past projects in VS Code or in iTerm2.

Expected behavior

container name will full url should be used.

Actual behavior

hardcoded ip

Additional context

Use the hostname of the container and the base url of the manager:

{{container_name}}.{{base_url}}

where base url is manager.os.mieweb.org
you would remove manager to get the base url.

I dont know if the code already knows the base url?

</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…Code and SSH links

Co-authored-by: horner <6094599+horner@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix hardcoded IP addresses in links Use container hostname + manager base URL instead of hardcoded IP in VS Code and SSH links Mar 15, 2026
Copilot AI requested a review from horner March 15, 2026 13:54
@horner horner requested a review from runleveldev March 15, 2026 15:58
@horner
Copy link
Member

horner commented Mar 15, 2026

@runleveldev please review.

@runleveldev
Copy link
Collaborator

runleveldev commented Mar 16, 2026

It's wrong to assume <container hostname>.<manager base domain> will resolve to the external IP of the site. This is normally the case for our deployment, but it's a hidden assumption that won't be true in all setups. There's a few ways we could more correctly address this:

  1. Concat container hostname and any ExternalDomain model entry with the current site as default. This is more likely to be correct in the general case than using the manager base domain, but still not fully enforced
  2. Find and use any externalHostname + externalDomain pairing from the container's associated HTTP(S) services. This will guarantee that the presented name resolves to the correct site IP, but requires that the container has at least on HTTP(S) service defined (we could use a fallback to IP if it doesn't)
  3. Continue to use the Site's externalIP, but somehow encode an alias of the container's name into it.

I think (2) is the best option here. I'll open a different PR to handle it.

@runleveldev
Copy link
Collaborator

Closing in preference of #243

@runleveldev runleveldev deleted the copilot/fix-hardcoded-ip-addresses branch March 16, 2026 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: "Open in VS Code" and "Open SSH in terminal" use hardcoded IP addresses

3 participants