Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add options for port forwarding #10

Open
lee-orr opened this issue Sep 12, 2024 · 12 comments
Open

Add options for port forwarding #10

lee-orr opened this issue Sep 12, 2024 · 12 comments

Comments

@lee-orr
Copy link

lee-orr commented Sep 12, 2024

The current approach to port forwarding used by lapdev hash.domain/proxy/port can cause issues when serving elements that expect access to the root of a given hostname (i.e. where the base url is "/").

It would be useful if alternative options - such as port-hash.domain - were available

@gitizenss
Copy link

^ Important for me as well.

Codespaces has the same issue and it makes most of their port forwarding useless.

But, port-hash.domain may not be necessary. It's possible to hide the route using reverse proxy, it's just not something most devs know can be done.

Really hoping the developers implement this though, it's pretty important.

@lyang2821
Copy link
Collaborator

lyang2821 commented Oct 9, 2024

port-workspacename.domain to forward a port is already supported. The port needs to be "exposed" in Dockerfile or devcontainer.

But we do need to show the port forwarding url in the dashboard, with the option that the port can be shared with other members in the same organization, or completely public.

@lee-orr
Copy link
Author

lee-orr commented Oct 9, 2024

When running in my dev container port-workspacename.domain does not work - it just routes to the list of workspaces/lapdev homepage. My example URL looks something like this: https://4321-lee-orr-a2x3mzwgbfto.domain.tld
This URL does work: https://lee-orr-a2x3mzwgbfto.domain.tld/proxy/4321/ - but it breaks absolute paths in my html.

The logs don't show anything, and the journalctl only shows the ```

Oct 09 15:29:10 lapdev.local lapdev[823]: websocket closed by client
Oct 09 15:29:10 lapdev.local lapdev[823]: websocket finished```

@lyang2821
Copy link
Collaborator

Which version are you running? That sounded like an old implementation of port fowarding

@lee-orr
Copy link
Author

lee-orr commented Oct 9, 2024

It's verion 0.1.0 (ran the install.sh from the site)

@lyang2821
Copy link
Collaborator

That version should be fine.

Can you please double check if the port is exposed? You can check in the workspace_port table in your database.

@lyang2821
Copy link
Collaborator

/proxy/port is probably a built in proxy in code-server.

@lee-orr
Copy link
Author

lee-orr commented Oct 11, 2024

The database seems to have no content... I can use see the structure:

# \dt
                List of relations
 Schema |        Name         | Type  |  Owner
--------+---------------------+-------+----------
 public | audit_log           | table | postgres
 public | config              | table | postgres
 public | machine_type        | table | postgres
 public | organization        | table | postgres
 public | organization_member | table | postgres
 public | prebuild            | table | postgres
 public | prebuild_replica    | table | postgres
 public | project             | table | postgres
 public | quota               | table | postgres
 public | seaql_migrations    | table | postgres
 public | ssh_public_key      | table | postgres
 public | usage               | table | postgres
 public | user                | table | postgres
 public | user_invitation     | table | postgres
 public | workspace           | table | postgres
 public | workspace_host      | table | postgres
 public | workspace_port      | table | postgres
(17 rows)

#  \d workspace_port
              Table "public.workspace_port"
    Column    |  Type   | Collation | Nullable | Default
--------------+---------+-----------+----------+---------
 id           | uuid    |           | not null |
 workspace_id | uuid    |           | not null |
 port         | integer |           | not null |
 host_port    | integer |           | not null |
 shared       | boolean |           | not null |
Indexes:
    "workspace_port_pkey" PRIMARY KEY, btree (id)
    "workspace_port_workspace_id_port_idx" btree (workspace_id, port)
Foreign-key constraints:
    "workspace_port_workspace_id_fkey" FOREIGN KEY (workspace_id) REFERENCES workspace(id)

but running: SELECT * FROM workspace_port returns nothing - and the same is true for every other table in the database that I tried.

It's particularly strange since both the user & workspace appear in the UI, but not in the database, for example.

(this is the database from /etc/lapdev.conf)

@lee-orr
Copy link
Author

lee-orr commented Oct 11, 2024

I did ensure the ports are exposed in the devcontainer files as well (tried both forwarded ports and app port)

@lyang2821
Copy link
Collaborator

The ports needs EXPOSE in Dockerfile.

@gitizenss
Copy link

image

Just dropping this here: Proxy almost never works for localhost webapps. Github codespaces and gitpod have the same issue.

What's funny is that it can be circumvented entirely by installing browse-lite extension, and doing 'npx playwright install --with-deps', and then setting chrome executable path in browse-lite's settings to /root/.cache/ms-playwright/chromium-1140/chrome-linux/chrome

Just like that, can access localhost sites without hair-pulling. Amazed no site has baked-in something similar yet

@lyang2821
Copy link
Collaborator

image

Just dropping this here: Proxy almost never works for localhost webapps. Github codespaces and gitpod have the same issue.

What's funny is that it can be circumvented entirely by installing browse-lite extension, and doing 'npx playwright install --with-deps', and then setting chrome executable path in browse-lite's settings to /root/.cache/ms-playwright/chromium-1140/chrome-linux/chrome

Just like that, can access localhost sites without hair-pulling. Amazed no site has baked-in something similar yet

The latest master now supports "forwardPorts" in devcontainer. And you can try it on ws.lap.dev.

You can see how it works on the Lapce repo. The below is a quick link to create a Lapce workspace.

https://ws.lap.dev/#github.com/lapce/lapce

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

No branches or pull requests

3 participants