0

Say I am doing something like this: (bsd variant of nc)

nc -k -l 8080 <fifo | nc 10.90.34.18 80 >fifo

This works great, I can use the server this is run on as a proxy to reach 10.90.34.18.

However, after performing a curl, it looks like the second nc command exits.

How can I prevent this?

3
  • What shell are you using?
    – camh
    Commented Jul 15, 2019 at 6:06
  • "This works great" Does it? How? What happens when the server on 10.90.34.18:80 closes the connection?
    – user313992
    Commented Jul 15, 2019 at 6:11
  • Shell is bash. When the server closes the connection I believe this is what causes the second netcat process to exit. I suppose it would be more correct to say "This works great for a single connection".
    – cat pants
    Commented Jul 15, 2019 at 9:02

1 Answer 1

1

The answer is to use a while loop like so:

while true
do
  nc 10.90.34.18 80 >fifo
done < <(nc -k -l 8080 <fifo)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .