I try to create an reverse proxy that work bidirectional. its different from apache that stateless reverse proxy. its means, device can host webserver without public ip. so far i can reverse static content without any problem, css, javascript. but, something like media that return 206 code. it broken in middle. it stop reverse proxy, and try to keep run the server again and again. and i got the video load full. what the problem? i think, it okay already. cause, i jsut forward everything as binary. not specific coding.
reverse proxy port 80 forward to express server in port 8080
import net from 'net';
const server = new net.Server();
server.on('connection', socket => {
socket.on('data', data => {
const client = new net.Socket();
client.connect({
host: '127.0.0.1',
port: 8080
});
client.write(data);
client.on('data', data => {
socket.write(data)
})
})
})
server.listen(80, () => {
console.log('server is running')
});