sshttp icon indicating copy to clipboard operation
sshttp copied to clipboard

Multiplexer fails when accessed on localhost

Open Bilaboz opened this issue 1 year ago • 0 comments

The multiplexer is working fine, except when accessing it from localhost

$ curl -v https://localhost:443
*   Trying 127.0.0.1:443...
* Connected to localhost (127.0.0.1) port 443
* ALPN: curl offers h2,http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* Recv failure: Connection reset by peer
*  CAfile: /etc/pki/tls/certs/ca-bundle.crt
*  CApath: none
* OpenSSL SSL_connect: Connection reset by peer in connection to localhost:443
* Closing connection
curl: (35) Recv failure: Connection reset by peer

$ curl -v http://localhost:443
*   Trying 127.0.0.1:443...
* Connected to localhost (127.0.0.1) port 443
> GET / HTTP/1.1
> Host: localhost:443
> User-Agent: curl/8.3.0
> Accept: */*
>
* Recv failure: Connection reset by peer
* Closing connection
curl: (56) Recv failure: Connection reset by peer

Log output: sshttpd[7668]: sshttp::loop::NS_Socket::bind_local::bind:Address already in use

The error seems to come from this bind() call https://github.com/stealth/sshttp/blob/91be220338249e9c7a937c8d9790f559a9fe1a60/src/socket.cc#L166

The CLI options passed to sshttp: ./sshttpd -S 2222 -L 443 -H 8851 -U nobody -R /var/empty

Listening ports on the instance:

ss -tunlp
Netid State  Recv-Q Send-Q                    Local Address:Port    Peer Address:Port Process
udp   UNCONN 0      0                               0.0.0.0:68           0.0.0.0:*     users:(("dhclient",pid=3492,fd=6))
udp   UNCONN 0      0                               0.0.0.0:111          0.0.0.0:*     users:(("rpcbind",pid=2951,fd=6))
udp   UNCONN 0      0                             127.0.0.1:323          0.0.0.0:*     users:(("chronyd",pid=3118,fd=5))
udp   UNCONN 0      0                               0.0.0.0:964          0.0.0.0:*     users:(("rpcbind",pid=2951,fd=7))
udp   UNCONN 0      0                                  [::]:111             [::]:*     users:(("rpcbind",pid=2951,fd=9))
udp   UNCONN 0      0                                 [::1]:323             [::]:*     users:(("chronyd",pid=3118,fd=6))
udp   UNCONN 0      0       [fe80::442:70ff:fea2:41a3]%eth0:546             [::]:*     users:(("dhclient",pid=3539,fd=5))
udp   UNCONN 0      0                                  [::]:964             [::]:*     users:(("rpcbind",pid=2951,fd=10))
tcp   LISTEN 0      100                           127.0.0.1:25           0.0.0.0:*     users:(("master",pid=3772,fd=13))
tcp   LISTEN 0      128                             0.0.0.0:443          0.0.0.0:*     users:(("sshttpd",pid=15226,fd=4),("sshttpd",pid=15225,fd=4),("sshttpd",pid=15224,fd=4),("sshttpd",pid=15223,fd=4))
tcp   LISTEN 0      128                           127.0.0.1:38757        0.0.0.0:*     users:(("containerd",pid=3617,fd=10))
tcp   LISTEN 0      128                             0.0.0.0:2222         0.0.0.0:*     users:(("sshd",pid=7946,fd=3))
tcp   LISTEN 0      128                             0.0.0.0:111          0.0.0.0:*     users:(("rpcbind",pid=2951,fd=8))
tcp   LISTEN 0      128                             0.0.0.0:80           0.0.0.0:*     users:(("nginx",pid=10603,fd=7),("nginx",pid=10602,fd=7),("nginx",pid=10601,fd=7),("nginx",pid=10600,fd=7),("nginx",pid=10598,fd=7))
tcp   LISTEN 0      128                             0.0.0.0:8851         0.0.0.0:*     users:(("nginx",pid=10603,fd=6),("nginx",pid=10602,fd=6),("nginx",pid=10601,fd=6),("nginx",pid=10600,fd=6),("nginx",pid=10598,fd=6))
tcp   LISTEN 0      128                             0.0.0.0:22           0.0.0.0:*     users:(("sshd",pid=7946,fd=5))
tcp   LISTEN 0      128                                [::]:2222            [::]:*     users:(("sshd",pid=7946,fd=4))
tcp   LISTEN 0      128                                [::]:111             [::]:*     users:(("rpcbind",pid=2951,fd=11))
tcp   LISTEN 0      128                                [::]:22              [::]:*     users:(("sshd",pid=7946,fd=6))

Environment

  • Amazon Linux 2023
  • sshttp Version: master

Bilaboz avatar Jul 22 '24 09:07 Bilaboz