0

I hope people can help me with this question.

Example:

My domain name is: example.com

My IP Address is 103.103.103.103

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
3

Assuming that you want requests to http://example.com to serve your website, and requests to http://103.103.103.103 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
    </VirtualHost>

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

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

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)... 127.0.0.1
Connecting to example.com (example.com)|127.0.0.1|: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 http://127.0.0.1

# wget -O-  http://127.0.0.1
--2018-03-09 15:35:28--  http://127.0.0.1/
Connecting to 127.0.0.1:80... 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: 103.103.103.103

iptables -A INPUT -m string --string "Host: 103.103.103.103" -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.