Avatar of Teera Char
Teera Char
Flag for Thailand asked on

check variable must send from specitic ip

Post variable must come from list of this ips 34.87.0.133,  35.197.144.151, 34.92.62.181, 34.92.96.157  How can I check it before process to receive variable are there any function in php or I must set in apache my operating system is linux



PHPLinuxApache Web Server

Avatar of undefined
Last Comment
ste5an

8/22/2022 - Mon
Kimputer

Check PHP variable $_SERVER['REMOTE_ADDR'] for those IP addresses and only process if the IP address is in your allowed list. That's if the server is used for other sites as well.
If it's ONLY serving those IP addresses, a firewall rule to allow only those IP's is sufficient.
arnold

What is the nature of your setup?
If you have a reverse proxy that might be more difficult. i.e. require authentication to have access to the resources.
ASKER CERTIFIED SOLUTION
gr8gonzo

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Teera Char

ASKER
thank you
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
ste5an

Depending on your requirements, the first point would be blocking all but your source IP's at the load balancer, then on the servers firewall.

When you need a more friendly response, then you could block it in .htaccess. Something like

deny from all     
allow from 34.87.0.133
allow from 35.197.144.151
allow from 34.92.62.181
allow from 34.92.96.157

Open in new window

Running it in PHP is wasting CPU resources.