this post was submitted on 06 Sep 2024
1 points (100.0% liked)

nginx

4 readers
1 users here now

The nginx community on Reddit. Reddit gives you the best of the internet in one place.

founded 1 year ago
MODERATORS
 
The original post: /r/nginx by /u/AleixoLucas on 2024-09-06 14:28:31.

https://preview.redd.it/648pzrrq87nd1.png?width=1919&format=png&auto=webp&s=bc55273dd1c732b587c521e1aee6d06d6326591c

Hello everyone, could you help me with this? I'm trying to block manual connections/Raw HTTP Request in my nginx, I'm doing a test like in the image, but it still returns 400, I wanted it to be 444; Do you know any other way to block this type of connection?

My docker compose:

name: nginx-httpe2ban
services:
  nginx:
    container_name: nginx-test
    volumes:
      - ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
    image: nginx:latest
    ports:
      - 8080:80
    environment:
      - NGINX_PORT=80

My nginx.conf

server {
    listen 80;
    server_name _;

    if ($host = "") {
        return 444;
    }

    location /401 {
        return 401;
    }
}

Raw command

echo -ne "GET / HTTP/1.1\r\n\r\n" | nc 127.0.0.1 8080

no comments (yet)
sorted by: hot top controversial new old
there doesn't seem to be anything here