0

There's something hitting a server I'm looking at a rapid rate and it's taking the site down. It's doing ...

POST /index.php/api/v2_soap/ HTTP/1.1, host: dev.mysite.com

I'd like to block all IPs to dev.mysite.com except for my IP.

I have the Nginx config file here: /etc/nginx/nginx.conf. [1]

I have the site-specific file here: /etc/nginx/sites-enabled/dev-mysite. [2]

I've tried the below in [2].

location / {
    ... # some other stuff
    allow 172.xx.xx.xx; # my IP   
    deny all;
  }

and it's blocking all traffic to dev.mysite.com except mine, but the POST request is still coming through, unless I configure the below in [1].

http {
    ...
    deny 216.xxx.xxx.xxx; # offending IP
    ...
}

Is there a way to modify just file [2] and achieve what I'm trying to do (deny all traffic except from my IP)?

laketuna
  • 125
  • 9
  • 1
    I would just add this into fail2ban. – Michael Hampton Jan 11 '17 at 05:29
  • @MichaelHampton He just want to block all IP's except the IP he has. he should try using .htaccess: http://stackoverflow.com/questions/4400154/deny-all-allow-only-one-ip-through-htaccess – Orphans Jan 11 '17 at 07:02
  • Have you tried [2] in the `server` block rather than in the `location` block? – Richard Smith Jan 11 '17 at 08:27
  • 1
    Why don't you just create an iptables entry, no need to fiddle with your webserver at all. Because if you don't block it at the Kernel-level (aka iptables) the request will still come through to your webserver which then has to handle it. htaccess is not a firewall. So either block the specific IP (favorable automate it with fail2ban like @MichaelHampton said) or block all IPs but your own. – Broco Jan 11 '17 at 09:19

0 Answers0