Is there any way to stop/block proxy servers to access https based sites ?.

As I have enabled mod_geoip to allow certain countries traffic, to access our critical websites, but still open web proxies are easily searchable by which any attacker try to access the site using the part of the allowed country.

I have googled a lot and found a solution to detect/block requests coming via proxy based on http-x-forwarded-for, (reference URL).

But this work only for HTTP based sites not for https, as on HTTPS x-forwarded-for headers are not coming due to encryption. So I believe is there must be some possible approach to block proxies for https, ?? else mod_geoip is useless for https based websites.


What are you trying to protect?

If some vulnerability then use modsecurity to migrate it and use IP black lists like https://github.com/mlsecproject/combine/wiki/Threat-Intelligence-Feeds-Gathered-by-Combine and block Tor exit nodes.

If you want to block just some countries then to use http-x-forwarded-for place the filter under web server or HAProxy that does ssl termination.

Other more complex solution is:

Note: One or two inital requests still won't be blocked but ones it's in black list it's bullet prove if you block it on iptables level.

Example: https://www.shodan.io/host/

This ip has proxy listening to port 8080 this is an public one. I tested it with one private I have and still you see open ports.

That can be done just by one python script as normal users won't have any open ports for hosted services.

Just take care not to ban google bots, use this guide: https://support.google.com/webmasters/answer/80553?hl=en&vid=0-292822248820-1519233445180

| improve this answer | |
  • Dear Hrvoje thank you for your feedback, actually I am using mod_geoip to only allow my country ips to access it. But it's useless as I see attacks coming from web proxies based on my country ips. I blocked proxy requests using x-forwared-for as mentioned above only for my HTTP sites but its not working for my HTTPS sites,as x-forwared-for not working in https due to SSL encryption. I want to protect my https sites from proxy servers. I m not using any load balancer or Haproxy as these are stand alone web servers. – user3485288 Feb 21 '18 at 18:06
  • No solution so far ? – user3485288 Feb 23 '18 at 12:21
  • As I said lookup for open ports on the client IPs if there is some open port block it. This can be done on netfilter level, custom nginx/apache module or with nfqueue or on app level with shodan api (faster then doing your self port scan and you don't expose you self with it). – Hrvoje Milković Feb 25 '18 at 12:59
  • I know you want a out of a box solution but there is none :/ – Hrvoje Milković Feb 25 '18 at 13:00
  • Thankyou so much Mr. Hrvoje for great response , can you please guide me how to control on netfilter level ? or apache module name ? please. – user3485288 Feb 28 '18 at 8:04

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