Edit:
@kasperd mentioned that you can set GatewayPorts for the user to you don't have to use nginx. I leave the workaround here for others.
Add this to /etc/ssh/sshd_config
Match User <username>
GatewayPorts yes
Original Answer:
I found a solution achieving this with ssh and nginx.
It is not perfect because i have to install a nginx server on A with a proxy.
I had to enable ssl and give this nginx instance a own ssl certificate.
So the Solution will look like this:
C will execute the following command to create a Relay between A and B:
ssh -R 445:1.0.0.2:444 user@1.0.0.1 -p 22
This will cause any input on Port 445 on 1.0.0.1 to be redirected to 1.0.0.2:444.
So a local user on A can now executewget https://localhost:445 --no-check-certificate
to get the index page of your webservice.
However it is not public available yet.
(in case you wonder: Port 445 is correct, i must use some unused port yet for the next part)
So i created a nginx server on A which will redirect any traffic from Port 443 to port 445. And used the following config:
server {
listen 443 ssl default_server;
listen [::]:443 ssl default_server;
ssl on;
ssl_certificate /etc/nginx/ssl/server.crt;
ssl_certificate_key /etc/nginx/ssl/server.key;
server_name proxy.<your-domain>.com;
location / {
proxy_pass https://127.0.0.1:445;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
}
}
Now you can use your webbrowser (in incognito mode on Firefox to prevent issues with the certificate) to suft to https://proxy..com:443 and get the result from your Webservice.
The IP of proxy..com must be 1.0.0.1.
What i dislike here is that i have to create a new webserver which will create a new encrypted session instead of just redirecting the one of my webservice located on B.
However this is a good workaround till i find a better solution.