无法将SSH隧道传输到远程服务器 [英] Trouble SSH Tunneling to remote server

查看:144
本文介绍了无法将SSH隧道传输到远程服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从本地计算机访问由IP锁定的远程供应商的网站(允许访问我们的公司服务器).我是通过从可以毫无问题地访问API的服务器上进行隧道传输来完成此操作的,但是,当我设置SSH隧道并转到供应商网站上的URL时,会收到404 Not Found错误.这是我正在使用的:

I am trying to get from my local machine to a remote vendor's website that is locked down by IP (our corporate servers are allowed access). I am doing this by tunneling from a server that can access the API without issues, however, when I setup the SSH tunnel and go to a URL on the vendor website, I get a 404 Not Found error. Here is what I'm using:

ssh -f -N user@example.com -L 7777:vendorhostexample.com:80

一切都表明隧道已正确设置,但是如果我尝试使用诸如"http://localhost:7777/foobar"之类的URL,则会收到404错误.有什么想法吗?

Everything indicates that the tunnel is setup correctly, but if I try a URL such as 'http://localhost:7777/foobar', I get the 404 error. Any ideas?

推荐答案

您的问题是您正在发送http标头"Location:localhost",这意味着如果目标Web服务器正在使用虚拟主机,它将尝试查找网站"localhost" ",而不是网站"vendorhostexample.com"

Your problem is you are sending the http header "Location: localhost" which means if the destination webserver is using virtualhosts, it will try to lookup for website "localhost" and not for website "vendorhostexample.com"

一种方法是Ryan指出的,它可以修改主机文件并告诉计算机vendorhostexample.com它位于127.0.0.1上,这样,当您在浏览器中键入该文件时,您将使用正确的主机: "http标头集.

One way is as Ryan pointed out to modify your hosts file and tell your machine that vendorhostexample.com it's on 127.0.0.1, that way when you type it in your browser you will go through the tunnel with the right "Host:" http header set.

另一种安装浏览器扩展程序的方法,用于更改Host标头,例如

Another way it's installing an extension for your browser to change the Host header like this one for firefox.

这篇关于无法将SSH隧道传输到远程服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆