0

An app on linux-based "headless-box-1" is listening for HTTP connections on http://127.0.0.1:7860. Which restricts connections to self.

But I wish it was listening for connections from any computer on the LAN.

Is there a command I can run on the headless-box-1 (192.168.1.100) that would allow me over on laptop-1 to browse to http://192.168.1.100 :7861, and it would bi-directionally route all the comms from lan-public port :7861 over to localhost-only :7860?

Security and HTTPS is not a concern in this setup. All the answers I found were for ssh-tunneling which had something to do with ssh over on the laptop side, which seems excessive.

Benjamin H
  • 155
  • 4
  • Check the documentation for the app. It's likely that the app's configuration allows you to specify which IP(s) it should listen on. Change the config to listen on your LAN IP instead of (or in addition to) the loopback IP. – Jim L. Oct 24 '22 at 19:24
  • Does this answer your question? [iptables redirect outside requests to 127.0.0.1](https://unix.stackexchange.com/questions/111433/iptables-redirect-outside-requests-to-127-0-0-1) – Philip Couling Oct 24 '22 at 22:45
  • I realise that question is asked from a different angle, but it looks like what you need. IE use `iptables` to forward requests to 127.0.0.1. – Philip Couling Oct 24 '22 at 22:46

1 Answers1

1

socat could be used for that:

socat tcp-listen:7861,reuseaddr,fork tcp:127.1:7860

Listens on 7861 on INADDR_ANY and plumbs the incoming connections to new TCP connections made to 127.1:7860

Stéphane Chazelas
  • 522,931
  • 91
  • 1,010
  • 1,501