10

I've created the following port forwarding:

ssh -vL localhost:4433:example.com:443 remote-linux-host

Note: I'm using 4433 on my local instead of 443 to avoid running with sudo.

however when I go to https://localhost:4433/, after ignoring the certificate check, there is the following error (on both Chrome and Firefox):

404 - Not Found

Same when using curl:

$ curl -s https://localhost:4433/ | html2text
<?xml version="1.0" encoding="iso-8859-1"?>
****** 404 - Not Found ******

How do I make the port forwarding for HTTPS?

My aim is to open https://example.com/ (which works fine over HTTPS) on my local (port 4433) via remote server.

kenorb
  • 20,250
  • 14
  • 140
  • 164

2 Answers2

13

Let´s suppose that example.com is 93.184.216.34.

One of the methods could be as follows.

Do:

ssh -L 4433:93.184.216.34:443 remote-linux-host

Define in your local /etc/hosts in the machine using the browser:

127.0.0.1 example.com

And then open in the browser: https://example.com:4433/

In this way, it will send the correct Host header.

Beware of browser/resolver DNS caches after creating the hosts entry.

kenorb
  • 20,250
  • 14
  • 140
  • 164
Rui F Ribeiro
  • 55,929
  • 26
  • 146
  • 227
4

To keep hostnames, SSL certs, etc. all happy, you could use the -D option to create a dynamic SOCKS4/5 proxy.

ssh -D 4444 username@ssh-hostname

Then on local machine set firefox/chrome to use said proxy.

ivanivan
  • 4,870
  • 1
  • 9
  • 20