ktock / container2wasm

Container to WASM converter
https://ktock.github.io/container2wasm-demo/
Apache License 2.0
2.03k stars 80 forks source link

How to setup HTTP server running inside container? #195

Open alienself opened 10 months ago

alienself commented 10 months ago

I would like to know how it would be possible to expose an HTTP server running inside the container to the outside page so that an iframe running on the same browser tab could potentially make a request to the container.

For instance let's say that my container is running nodejs with express like so:

const express = require('express')
const app = express()
const port = 3000

app.get('/', (req, res) => {
  res.send('Hello World!')
})

app.listen(port, () => {
  console.log(`Example app listening on port ${port}`)
})

Is that something that is even possible without some sort of proxy server? I would like to keep everything running locally.

ktock commented 10 months ago

an iframe running on the same browser tab could potentially make a request to the container.

This is not implemented as of now. If needed, it would be good to fix the networking stack (c2w-net-proxy) to add such feature, using additional fds maybe.

Seanw265 commented 9 months ago

Seems like this enhancement would allow container2wasm to compete with the closed-source WebContainers project.