0

I've been following a blog on how to compile modsecurity with nginx, Blog. I tried to verify that everything works with creating the file /etc/nginx/conf.d/echo.conf which contains:

    server {
       listen localhost:8085;
       location / {
            default_type text/plain;
            return 200 "Thank you for requesting ${request_uri}\n";
           }
    }

I ran the following in cmd:

    sudo nginx -s reload
    curl -D - http://localhost:8085 HTTP/1.1 200 OK

and I got

HTTP/1.1 200 OK
Server: nginx/1.19.0
Date: Wed, 10 Jun 2020 19:31:08 GMT
Content-Type: text/plain
Content-Length: 27
Connection: keep-alive

Thank you for requesting /
curl: (6) Could not resolve host: HTTP

I have been on this for hours and can't figure out what to do. The two solutions I've found were

  • IPv6 enabled
  • Wrong DNS server

I ran the command in cmd with --ipv4 curl --ipv4 -D - http://localhost:8085 HTTP/1.1 200 OK with no success. I also changed the nameserver in /etc/resolv.conf to 8.8.8.8 instead of 127.0.0.53 which also didn't work.

Any clues on what to do?

Ulvar
  • 23
  • 1
  • 1
  • 8
  • That's because you do not pass any host header. And according your config, you did not specify any host (server_name) – mgsxman Jun 10 '20 at 20:02

1 Answers1

1

That error message spawns due to the command syntax you used. When using curl it should be enough by running:

curl -D - http://localhost:8085 

To make a HTTP request to the webserver you define (localhost in this case). Otherwise it will take additional arguments as extra URLs to query if there are not additional options to parse, so it is trying to query HTTP as if you typed http://HTTP, which simply will not work, at least until you define a specific entry for HTTP host in your /etc/hosts for example.

mtnezm
  • 1,009
  • 1
  • 7
  • 19