I hope people can help me with this question.


My domain name is: example.com

My IP Address is

When people try to connect to my IP on port 80. It will not respond any request.

It should show: connecting(on browser)... with no response.(It will look like unable to connect)

I have tried to modify httpd.conf(i'm using apache 2.4) but not successful yet.

I tried googling but there is no result for my question.

Thank you

  • All the communication is done by IP addresses. A connection would have to be established for the web server to know what address was used in the browser. You can't do what you're trying to. – yoonix Mar 8 '18 at 23:35
  • With Apache???? Nginx you can return 444; – Jacob Evans Mar 9 '18 at 0:34
  • 1
    A firewall will do that, but the purpose of a web server is to answer requests. Why would you configure a web server to not respond to any requests? – Andrew Schulman Mar 9 '18 at 0:35
  • 4
    Just shut down your web server. Then it will no longer respond. – Michael Hampton Mar 9 '18 at 0:48
  • LOL! Sorry for this stupid question when I got the answers LMAO. I have idea to protect my server by a small ddos stress test. I’m using cloudflare to hide my ip. I just want to anti ddos with this idea. But look like it is not available to do lol – Jane Thorne Mar 9 '18 at 11:53

Assuming that you want requests to http://example.com to serve your website, and requests to to be explicitly dropped you have 2 main options that I am aware of.

1) is to use mod_security module and the drop target. A configuration like this;

    <VirtualHost *:80>
        ServerName default.only
        SecRuleEngine On
        SecRule REMOTE_ADDR "^\d" id:'1234',drop,phase:1

    <Directory /var/www/example.com >
      Options FollowSymLinks
      AllowOverride FileInfo Options
      Order allow,deny
      Allow from all

    <VirtualHost *:80>
        ServerName example.com
        DocumentRoot /var/www/example.com

returns the website, if you go to http://example.com

# wget -O-  http://example.com
--2018-03-09 15:35:35--  http://example.com/
Resolving example.com (example.com)...
Connecting to example.com (example.com)||:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 24 [text/html]
Saving to: ‘STDOUT’

and if you try to go to the default site via ip

# wget -O-
--2018-03-09 15:35:28--
Connecting to connected.
HTTP request sent, awaiting response... No data received.

The connection is dropped

2) The second option is to use the string module for iptables and drop connections with a header matching Host:

iptables -A INPUT -m string --string "Host:" -j DROP

(I didn't test that iptables rules...so you would have to check the docs for the correct incantation...) However I think the mod_security option is simpler

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.