curl command hang on nginx server while uploading file thourgh stdin

704 Views Asked by At

First of all, I am trying to implement a repl server for my node.js application, I've created it with the help of this gist. everything is fine and I can connect to my repl server with this command in the localhost:

$ curl -sSNT. localhost:8000
Welcome to the Fun House
> echo me
echo me
> echo me again
echo me again
> bye
bye
> ^C

but when I try to use nginx as the reverse-proxy, this command got hanged and no output is displayed:

$ curl -sSNT. test.localhost:8083 -I
HTTP/1.1 100 Continue

It hangs forever.

Steps to reproduce the problem:

  1. git clone https://github.com/mostafa8026/nginx-repl-curl.git
  2. cd nginx-repl-curl
  3. docker-compose build
  4. add test.localhost to your hosts
127.0.0.1       localhost test.localhost
  1. docker-compose up -d
  2. and the main problem: curl -sSNT. test.localhost:8083 -I

EDIT

As mentioned in the answers, we can try writing and then press Ctrl+D, but it closes the connection, as a repl server, the main purpose is to keep the connection open and send command like in the command line like this:

$ curl -sSNT. localhost:8000
Welcome to the Fun House
> echo me
echo me
> echo me again
echo me again
> bye
bye
> ^C

not like this:

curl -sSNT. test.localhost:8083 -I
HTTP/1.1 100 Continue

echo me
HTTP/1.1 200 OK
Server: nginx/1.21.1
Date: Sat, 09 Apr 2022 12:58:37 GMT
Content-Type: multipart/octet-stream
Transfer-Encoding: chunked
Connection: keep-alive

Welcome to the Fun House
> echo me
> Ended

It hangs here
^C
1

There are 1 best solutions below

3
Def Soudani On

It's hanging because it's waiting for you to write something(file to be uploaded) to stdin

write something hit enter then ctrl+D

Test of answer

$ curl -sSNT. test.localhost:8083 -I
HTTP/1.1 100 Continue

Here's a test 
mostafa8026    
HTTP/1.1 200 OK
Server: nginx/1.21.6
Date: Sat, 09 Apr 2022 11:41:35 GMT
Content-Type: multipart/octet-stream
Transfer-Encoding: chunked
Connection: keep-alive

Welcome to the Fun House
> Here's a test 
mostafa8026
> Ended