How to use TraeFIk to make IP judgment?

Hey guys, I need to use TraeFIk to determine the IP of a country or region. How can I determine the IP of a region within TraeFIk and redirect that IP to a web page?

Hi @yuechen-91! Traefik does not provide the ability to route based on IP location. However, since Traefik v2.3 you can write your own plugins:

As plugins can be set on routers like any middlewares, you could write your own to ask an external service where the source IP comes from. Then you can redirect to the right backend.

An other solution, would be to check on your backend if the source IP is from an expected location and if it doesn't, return a specific error code. Then on you router you can use the errors middleware to redirect to the appropriate service.

Well, thank you very much for your reply

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.