0

I haven't tried in a different machine, but I am trying to establish an ssh tunnel to an external server. This how I am doing it:

ssh -L 9898:firewalled.service.com:443 user@some-server

I have 2 problems on this:

  1. while accessing to localhost:9898, I get:

400 Bad request: The plain HTTP request was sent to HTTPS port.

and I get

Cannot Get /

If trying https://localhost:9898

  1. If I close the ssh connection, and I run nmap to localhost, I get many ports opened.

Ports that I have tried and now appear in nmap:

$nmap -T4 localhost
| PORT     | STATE | SERVICE   |
| 6666/tcp | open | irc        |
| 7777/tcp | open | cbt        |
| 8080/tcp | open | http-proxy |
| 9876/tcp | open | sd         |
| 9898/tcp | open | monkeycom  |
| 9999/tcp | open | abyss      |

This are all attempts of ssh tunnels, all connections are already closed, but this are still showing in nmap.

I know these ports are open and listening to something, I can even talk to them:

nc -z localhost 9999
Connection to localhost port 9999 [tcp/distinct] succeeded!

What is the reason behind this?

I am using Macos Mojave for all of this.

  • The error is quite clear *”The plain HTTP request was sent to HTTPS port.”* - You should use `httpS://localhost:9898` rather than plain http `http://localhost:9898` (and ignore any browser warnings you will get about mismatching TLS certificates) – HBruijn Apr 24 '19 at 23:32
  • I edited the question to clarify that https doesn't work either. I googled this, and it seems to be an nginx bad config, but turns out I am not even using nginx on firewalled.service.com, nor in some-server. I checked the apache logs in the remote server, and I am not even hitting it, my guess is that I am not even leaving my localhost. – Simon Ernesto Cardenas Zarate Apr 24 '19 at 23:41
  • I had same issue, but if I replace localhost with 127.0.0.1, it was solved. – JOA80 Feb 24 '22 at 05:47

1 Answers1

0

I would suggest you to try something like:

ssh -v -L 1.2.3.4:9898:5.6.7.8:443 user@2.4.6.8

Where:

1.2.3.4 = Your PC IP Addr

5.6.7.8 = The remote target resource

2.4.6.8 = The remote SSH server

Then, try in your browser = https://1.2.3.4:9898

PD: Keep in mind that 9898, 443 or any other number don't mean secure or not. Secure is the application layer, in this case SSL. The problem would be more how the application and / or the remote web server works. For instance, something similar has happened to me when trying to open Graylog through the same method. Some applications support be opened from localhost, but some others no.

Saludos.

enter image description hereenter image description here