Is there a built in software way to essentially port forward like the following?

example.com/81/* -> example.com:81/*
example.com/82/* -> example.com:82/*

Alternatively maybe for subdomains something similar?

example.com/a/* -> a.example.com/*
example.com/b/* -> b.example.com/*

I understand there may be speed issues but I would like to essentially access all ports on my machine when only being able to open one port through my router.

I believe I can feasible get this to work with pipes with node.js but this seems like it may be a common need.

EDIT: I like I stated only have one port to work with for communication with a computer. Its behind a firewall. Besides sshing into the machine I would like an easy way to access the other ports on the server(only 1 port to access) that isn't very intensive.

  • Since it appears telcoM's answer isn't what you're looking for, could you go back a few steps and explain what problem you're trying to solve? Right now, it seems you've come up with a solution and either are struggling to explain it to us and/or it isn't technically possible, and thus we've been unable to help. But if you go back a few steps, explain the higher-level problem you're aiming to solve, I think that'd help us to understand the goal. – derobert Nov 1 '18 at 14:59

If I understood your question correctly, that's not really port forwarding but HTTP reverse proxying (with some URI manipulation added), and that would only be applicable for HTTP-speaking services.

In your first example:

example.com/81/* -> example.com:81/*

the client would have to connect to example.com:80 and then send out a syntactically valid HTTP request (e.g. a GET request) for an URI that matches /81/*, and then the reverse proxy would connect on client's behalf to example.com:81, and re-submit the request, modified by deleting the initial /81 from it.

If you attempted to connect to e.g. an IMAP mail service in example.com:143 in this way, the mail client would have to, instead of just connecting to the target address and port, connect to port 80 on the target and send a message like this:

CONNECT example.com:143 HTTP/1.1

...and then continue using the standard IMAP protocol.

No standard mail client I know of has such a feature, although it would be technically possible to implement it. Also, the CONNECT method of HTTP is security-sensitive and its use should be strictly controlled: unrestricted HTTP proxies that allow CONNECT are easy targets for abuse.

  • A port/url identifier can return whatever protocol it would like I thought. It just a port/path so I'm not sure why http speaking services would only be relevant. If it makes more sense expand the port client side on the users machine. -> example.com/81/* -> example.com:81/* – William Nov 1 '18 at 14:16
  • You're correct that specifying the hostname/IP:port part is protocol-agnostic in the sense you're thinking of, but the URI part is not. Specifying the /81/* part to the server requires communicating with the port, which requires the use of a protocol in the same way as speaking requires the use of a language. "Expand the port client side" sounds like you're looking for a HTTP tunneling solution like chisel. – telcoM Nov 1 '18 at 14:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.