Is it possible to restrict traffic to specific IP addresses within Treepl?

Is it possible to restrict traffic to specific IP addresses within Treepl? We have a customer that wants their secure zone to only be available on specific IP Addresses.

On your login page you could do something like

{% if request.request_data.ip == “XX.XXX.XXX” %} X= ip address
Insert Login form here
{% endif %}

This will only show the login form if they are using a computer from a specific IP Address.
This only works if they have a static ip address.

Do users from this specific ip address still need to enter a password? If not you could do your template file like that:

{% if request.request_data.ip == “XX.XXX.XXX” %}
content
{% else %}
<p>This page is restricted</p>
{% endif %}

You could probably use the IP as the password but the account would have to be setup the ip address as the password. Not something I think I would do.

No, what I mean is more like: Should all users coming from that IP address have access to that page. In that case you woudn’t need to setup a secure zone in the first place. Just hardcode the user restriction via liquid condition into the template. For better convenience the IP address could be setup as a varibale in “site information” so the admin can change it without touching the template.

Note of caution: this setup may be susceptible to IP spoofing. So the implementation may depend on the level of security you need.

1 Like