-3

I want to restrict access to a path via iptables - I try this one and its work on the whole site

iptables -I INPUT -p tcp --dport 443 -m string --algo bm --string 'example.com' -j DROP

but I want to restrict access to specific folder like "example.com/test", but It didn't catch any packets

iptables -I INPUT -p tcp --dport 443 -m string --algo bm --string 'example.com/test' -j DROP

Please any suggestion ?

Sven
  • 98,649
  • 14
  • 180
  • 226

2 Answers2

2

Wrong network layer. While you probably could do some horrible hackjob to block that via IPTables on unencrypted http, https is encrypted so IPTables dont even see full URL string. There are 2 solutions:

  • Put your site behind a reverse proxy like HAProxy + decrypt SSL (HAProxy 1.5 can do that, or you can put stunnel/nginx before it to decrypt SSL)
  • Block it on whatever target server you are using
XANi
  • 391
  • 1
  • 3
2

Just use the permission system of your web server, e.g. via .htaccess files in case of Apache.

Sven
  • 98,649
  • 14
  • 180
  • 226