Centos
無法連接到埠 4430 上的 localhost
我正在
vagrant
執行virtual box
並CentOS
安裝Nginx
。我已經創建了從 vagrant box 到遠端伺服器的反向隧道,但是當我嘗試連接到埠 4430 上的本地主機時,我在執行命令時不斷收到以下錯誤:curl -v 'https://localhost:4430' * About to connect() to localhost port 4430 (#0) * Trying ::1... Connection refused * Trying 127.0.0.1... Connection refused * couldn't connect to host * Closing connection #0 curl: (7) couldn't connect to host
我一直在嘗試在瀏覽器中載入該網站,但 Chrome 也會引發錯誤。
This webpage is not available ERR_CONNECTION_REFUSED
我想要做的是創建一個似乎工作正常的反向隧道,因為我可以連接到遠端機器並創建隧道,但我無法在本地機器上使用所需的(反向埠)瀏覽。
這是我的隧道腳本:
ssh -v -R 4430:localhost:443 user@remote-domain.com -N
有誰知道問題可能是什麼?
我可以使用埠 443 進行連接,但不能使用 4430!
任何幫助,將不勝感激!
更新
執行以下命令會給出以下輸出
ssh -v -R 4430:localhost-domain:443 ec2-user@vm.domain.com -N debug1: Reading configuration data /etc/ssh/ssh_config debug1: Applying options for * debug1: Connecting to vm.domain.com [54.149.189.155] port 22. debug1: Connection established. debug1: identity file /home/vagrant/.ssh/identity type -1 debug1: identity file /home/vagrant/.ssh/identity-cert type -1 debug1: identity file /home/vagrant/.ssh/id_rsa type 1 debug1: identity file /home/vagrant/.ssh/id_rsa-cert type -1 debug1: identity file /home/vagrant/.ssh/id_dsa type -1 debug1: identity file /home/vagrant/.ssh/id_dsa-cert type -1 debug1: identity file /home/vagrant/.ssh/id_ecdsa type -1 debug1: identity file /home/vagrant/.ssh/id_ecdsa-cert type -1 debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1 debug1: match: OpenSSH_6.6.1 pat OpenSSH* debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_5.3 debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: server->client aes128-ctr hmac-md5 none debug1: kex: client->server aes128-ctr hmac-md5 none debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP debug1: SSH2_MSG_KEX_DH_GEX_INIT sent debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY debug1: Host 'vm.domain.com' is known and matches the RSA host key. debug1: Found key in /home/vagrant/.ssh/known_hosts:1 debug1: ssh_rsa_verify: signature correct debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: SSH2_MSG_SERVICE_REQUEST sent debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey debug1: Next authentication method: publickey debug1: Trying private key: /home/vagrant/.ssh/identity debug1: Offering public key: /home/vagrant/.ssh/id_rsa debug1: Server accepts key: pkalg ssh-rsa blen 277 debug1: read PEM private key done: type RSA debug1: Authentication succeeded (publickey). debug1: Local connections to LOCALHOST:4430 forwarded to remote address localhost-domain:443 debug1: Local forwarding listening on ::1 port 4430. debug1: channel 0: new [port listener] debug1: Local forwarding listening on 127.0.0.1 port 4430. debug1: channel 1: new [port listener] debug1: Requesting no-more-sessions@openssh.com debug1: Entering interactive session.
我在想
LOCALHOST:4430
應該是流浪盒的主機名?例如local-domain:4430
我認為您缺少該
-g
選項,因為否則遠端埠將僅在偵聽localhost
,這意味著除遠端之外的任何其他主機localhost
都無法連接到它。有了
-g
它聽0.0.0.0
,這意味著它在所有介面上都可用,而不僅僅是localhost
.正如選項
ssh(1)
“g
允許遠端主機連接到本地轉發埠。如果在多路連接上使用,則必須在主程序上指定此選項。”你還提到你在一個流浪者盒子裡創建了這個隧道。所以
curl
你展示的這個也在流浪者盒子裡,對吧?否則,如果您curl
在主機系統上執行,而不是在 vagrant box 內,那將無法工作。如果您想從主機系統(不在 vagrant box 內)連接到隧道,您必須連接到 vagrant box 的 IP 而不是127.0.0.1
.