URL access to specific IP only

I need help or input on below. I have two VPS server. One VPS is main server having Live website named www.example.com while the other VPS server is having
Live Help & Live Chat on it with URL www.mychat.com. This www.mychat.com/index.php?userid is getting called from www.example.com via a iframe.

I want to secure www.mychat.com so that if it gets called from IP of www.example.com then only it should work else direct getting called from any browser,
it should not work. I mean it should be html called or src or href from example.com then only www.mychat.com/index.php?userid should work.

I have two options

1. In Apache on www.mychat.com/index.php?userid , I should allow only IP of www.example.com
2. In Iptable of www.mychat.com/index.php?userid, I should allow only IP of www.example.com

Please advice with all the details.

 

 

 

 

Top