0

Is it possible to run nginx inside wasm in the browser?

I'm imagining a webpage where you can enter an nginx config in a text box and then run nginx in wasm with an example request to get the output.

Test
  • 962
  • 9
  • 26

1 Answers1

2

No, this is not possible.

Despite the fact that you cold compile nginx into wasm, nginx will try to make system calls to open up sockets to handle requests. The browser's WASM engine does not support socket creation, and these calls would fail, killing your program.

However, with some effort, you could modify nginx to not actually create a web server, and instead supply it with your example response. By avoiding the creation of an actual web server, you should be able to get the functionality you describe.

It's worth acknowledging that this would be very difficult. nginx is full of system calls that you would need to patch out, and modifying the control flow so majorly would require intimate farmiliary with nginx internals.

Carson
  • 2,700
  • 11
  • 24