0

i'm trying to make nginx as proxy_server to nodejs app on port 3000 for testing purpose with compression, when doing this:

curl -I -H 'Accept-Encoding: gzip, deflate' http://localhost/json

i go this:

curl -I gives a 404 error

and when curl it with -i with body shown

curl -i -H 'Accept-Encoding: gzip, deflate' http://localhost/json

i got this:

with 200 status

in nginx.conf file:

location / {
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_pass http://localhost:3000;
}

in node app.js

//..
app.get('/json',(req,res)=>{
    res.json({Hello:'JSON'})
});

and again this seems weird when send some text for testing gzip

app.get('/', (req,res)=>{
    res.end('lorem ipsum ........ 100(lorem ipsum long text) ');
});

the content not reduced but when i add explicitly content-type the content size got compressed.

app.get('/', (req,res)=>{
    res.setHeader('Content-type','text/html');
    res.end('lorem ipsum ........ 100(lorem ipsum long text) ');
});
Uwe Keim
  • 2,420
  • 5
  • 30
  • 47

1 Answers1

0

-I makes a HEAD request while -i makes a GET request.

Your app most probably only answers GET requests.

Gerald Schneider
  • 23,274
  • 8
  • 57
  • 89
  • Thanks, i didn't knew that there was a HEAD request, just printed out the req.method, i thought it ll just print out the response header by using -i( like not full response only header) so while i was doing .get() it sais 404 since there was no handler for HEAD request. – Younes Keraressi Dec 08 '20 at 16:19