Question

Best way to prevent ip from outside USA from accessing angular frontend using nginx-ingress in k8s?

Currently looking for the best way to limit network access via ip to angular frontend using kubernetes nginx-ingress for ip addresses outside of the USA. I can see firewalls created with no rules for public access, but it seems like I have limited options for including logic to filter based on region. It would be painful to maintain a whitelist for obvious reasons from this view.

I am also aware of MaxMind’s GeoIP2 and using lua logic on the ingress, but I would prefer to use an easier option and was hoping DigitalOcean has something implemented for this use case that I am not seeing yet.

Thanks for the ideas/help!


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

alexdo
Site Moderator
Site Moderator badge
January 18, 2024

Hello there,

You can also use a third-party providers like CloudFlare that have Firewall features where you can block access from certain IP addresses or whole country IP ranges. They also regularly update their IP lists which means you’re likely to bypass some requests coming from proxies.

Just enter an IP address, an IP range, or a two-letter country code you wish to block

https://serverpilot.io/docs/how-to-block-ips-with-cloudflare/

Hope that helps!

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.