SirDice with ssh remote port forwarding a client maps something bound on his interfaces/ports to server interfaces/ports.
Code:
ssh –R 8100:localhost:8200 user@server.com
Any connections to server.com:8100 end up on localhost:8200. If you bind a webserver at localhost:8200, that server is accessible from the internet via server.com:8100.
Say you have a local web server running HTTPS at port 443, and you assign it certificate chain valid for server.com.
On server.com you don't have anything running on that port. When you do
Code:
ssh –R 443:localhost:443 root@server.com
You make your localhost the server.com webserver with valid chain of trust.
You cannot make proper reverse DNS and other entries, for instance TXT needed for letsencrypt challenge, for that localhost. You can for server.com which just acts as a connection point in this case.
Again noting, only problem here is port 443 and inherent quirkiness of arbitrary ports when it comes to DNS. The 443 redirect requires root ssh login. I want to avoid that.
Ok i understand now what are you trying to do. I don't thing it's the right tho. You can do it with a vpn to the dev machine where he can host the site.
Anyway let me explain how similar setup is organized on single hosting, it would be better to be on separate independent hosting but here it is.
On the hosting i have virtualhosts one for production
www.example.com and another one for dev.example.com with separate MySQL databases and with htaccess for the dev site. Both can be accessed for testing and can be easy swap or migrated with minimum or no downtime. Devs have ftp and db access where they can upload and make changes to the sites instead of hosting it on they own machines.
Let me give some extra context here, it isn't about the hosting, it's about accessing a development webserver running deep inside a network on a normal computer, not in DMZ, behind layers of firewalls. In this case I can rely on users having root but that is not really the hard fact. Users may not have root. VPN maybe off limits. Outbound ports might be restricted.
Since this is my development team I'm also willing to give them root and avoid all this, but I'm curious to do it the proper way.
This is the example for Linux/iptables
Code:
iptables -t nat -A PREROUTING -d 123.123.123.123 -p tcp --dport 443 -j REDIRECT --to-port 8443
Ssh worker spawn descalated to logged in user, can bind normally to 8443 and route whatever user is having on its localhost end to it. The firewall will rewrite packets incoming from Internet to 443 to hit that 8443 on the same interface, where ssh worker spawn tunnels all packets back to the localhost machine where web server is. Thus
https://123.123.123.123 ends up somewhere on the users localhost while being intermediary redirected over 123.123.123.123:8443 due to inability of non-root ssh spawn to hook up privileged ports.
So I guess a direct question would be how to write that iptables rule in PF.