First, why do you need to whitelist PayPal IP address?
In my case I needed to do that on a staging server where the client sites are only accessible via a password (Basic Authentication method) and the site had an e-commerce component.
Steps
1. Get the most recent PayPal IP addresses from this link.
https://ppmts.custhelp.com/app/answers/detail/a_id/92
2. From the dropdown select ipnpb.paypal.com
Next you have the IP list but depending on the web server we need to have some text before and after the IP address.
3. To append and prepend text use our Prepender Appender (from Orbisius Tools)
For Apache for prepend text use: "Allow from "
Omit the quotes of course but do make sure there is a space after 'from'.
For nginx for prepend text use: "allow " and for append text use ";"
Omit the quotes of course but do make sure there is a space after 'allow'.
4. Copy the modified text.
5. Installation
You can either add it to .htaccess or the vhost (apache). For nginx you have to add it to the vhost.
To add it to the vhost (ubuntu)
Create a file /etc/apache2/conf-available/custom-whitelist-paypal-ips.conf with the following contents.
# ipnpb.paypal.com ; Last updated: 2014-12-20 # https://ppmts.custhelp.com/app/answers/detail/a_id/92 allow from 173.0.84.8 allow from 173.0.84.40 allow from 173.0.88.8 allow from 173.0.88.40 # Aug 2014 allow from 173.0.92.8 allow from 173.0.93.8 allow from 64.4.249.8 allow from 64.4.248.8 # Additional IP addresses coming later in 2014: allow from 2.22.141.54 allow from 23.4.189.54 allow from 23.4.36.66 allow from 23.4.61.54 allow from 23.5.13.54 allow from 23.5.253.54 allow from 23.7.77.54 allow from 23.7.141.54 allow from 23.9.125.54 allow from 23.9.84.66 allow from 23.13.173.54 allow from 23.13.29.54 allow from 23.15.157.54 allow from 23.34.205.54 allow from 23.34.221.54 allow from 23.34.228.66 allow from 23.35.109.54 allow from 23.35.13.54 allow from 23.35.173.54 allow from 23.35.221.54 allow from 23.35.29.54 allow from 23.35.45.54 allow from 23.35.61.54 allow from 23.35.93.54 allow from 23.36.13.54 allow from 23.37.141.54 allow from 23.37.173.54 allow from 23.37.189.54 allow from 23.37.36.66 allow from 23.38.29.54 allow from 23.38.93.54 allow from 23.41.141.54 allow from 23.41.157.54 allow from 23.41.174.218 allow from 23.41.77.54 allow from 23.42.13.54 allow from 23.42.29.54 allow from 23.43.13.54 allow from 23.43.141.54 allow from 23.43.157.54 allow from 23.43.68.66 allow from 23.44.157.54 allow from 23.44.253.54 allow from 23.46.109.54 allow from 23.46.125.54 allow from 23.46.45.54 allow from 23.46.77.54 allow from 23.47.237.54 allow from 23.47.253.54 allow from 23.47.29.54 allow from 23.49.125.54 allow from 23.49.141.54 allow from 23.49.157.54 allow from 23.49.77.54 allow from 23.49.93.54 allow from 23.50.109.54 allow from 23.50.157.54 allow from 23.50.189.54 allow from 23.50.205.54 allow from 23.50.77.54 allow from 23.50.93.54 allow from 23.51.125.54 allow from 23.51.237.54 allow from 23.51.244.66 allow from 23.51.29.54 allow from 23.51.45.54 allow from 23.52.157.54 allow from 23.52.29.54 allow from 23.52.61.54 allow from 23.52.93.54 allow from 23.53.109.54 allow from 23.53.157.54 allow from 23.53.189.54 allow from 23.53.29.54 allow from 23.53.93.54 allow from 23.54.109.54 allow from 23.54.141.54 allow from 23.54.189.54 allow from 23.54.237.54 allow from 23.54.93.54 allow from 23.55.157.54 allow from 23.56.157.54 allow from 23.57.109.54 allow from 23.57.221.54 allow from 23.57.237.54 allow from 23.58.160.37 allow from 23.58.45.54 allow from 23.59.141.54 allow from 23.60.141.54 allow from 23.61.189.54 allow from 23.61.77.54 allow from 23.62.253.54 allow from 23.63.141.54 allow from 23.64.173.54 allow from 23.64.93.54 allow from 23.65.13.54 allow from 23.65.141.54 allow from 23.74.21.54
in the vhost use add this line
Include /etc/apache2/conf-available/custom-whitelist-paypal-ips.conf
as root run
apachectl configtest
if everything looks good then do
service apache2 reload
if you're adding this to .htaccess you don't need to create the conf file obviously just append it to the .htaccess file.
Here is the file for nginx.
Create a file in /etc/nginx/conf.d/custom-whitelist-paypal-ips-dont-autoload
# ipnpb.paypal.com # https://ppmts.custhelp.com/app/answers/detail/a_id/92 allow 173.0.84.8; allow 173.0.84.40; allow 173.0.88.8; allow 173.0.88.40; # Aug 2014 allow 173.0.92.8; allow 173.0.93.8; allow 64.4.249.8; allow 64.4.248.8; # Additional IP addresses coming later in 2014: allow 2.22.141.54; allow 23.4.189.54; allow 23.4.36.66; allow 23.4.61.54; allow 23.5.13.54; allow 23.5.253.54; allow 23.7.77.54; allow 23.7.141.54; allow 23.9.125.54; allow 23.9.84.66; allow 23.13.173.54; allow 23.13.29.54; allow 23.15.157.54; allow 23.34.205.54; allow 23.34.221.54; allow 23.34.228.66; allow 23.35.109.54; allow 23.35.13.54; allow 23.35.173.54; allow 23.35.221.54; allow 23.35.29.54; allow 23.35.45.54; allow 23.35.61.54; allow 23.35.93.54; allow 23.36.13.54; allow 23.37.141.54; allow 23.37.173.54; allow 23.37.189.54; allow 23.37.36.66; allow 23.38.29.54; allow 23.38.93.54; allow 23.41.141.54; allow 23.41.157.54; allow 23.41.174.218; allow 23.41.77.54; allow 23.42.13.54; allow 23.42.29.54; allow 23.43.13.54; allow 23.43.141.54; allow 23.43.157.54; allow 23.43.68.66; allow 23.44.157.54; allow 23.44.253.54; allow 23.46.109.54; allow 23.46.125.54; allow 23.46.45.54; allow 23.46.77.54; allow 23.47.237.54; allow 23.47.253.54; allow 23.47.29.54; allow 23.49.125.54; allow 23.49.141.54; allow 23.49.157.54; allow 23.49.77.54; allow 23.49.93.54; allow 23.50.109.54; allow 23.50.157.54; allow 23.50.189.54; allow 23.50.205.54; allow 23.50.77.54; allow 23.50.93.54; allow 23.51.125.54; allow 23.51.237.54; allow 23.51.244.66; allow 23.51.29.54; allow 23.51.45.54; allow 23.52.157.54; allow 23.52.29.54; allow 23.52.61.54; allow 23.52.93.54; allow 23.53.109.54; allow 23.53.157.54; allow 23.53.189.54; allow 23.53.29.54; allow 23.53.93.54; allow 23.54.109.54; allow 23.54.141.54; allow 23.54.189.54; allow 23.54.237.54; allow 23.54.93.54; allow 23.55.157.54; allow 23.56.157.54; allow 23.57.109.54; allow 23.57.221.54; allow 23.57.237.54; allow 23.58.160.37; allow 23.58.45.54; allow 23.59.141.54; allow 23.60.141.54; allow 23.61.189.54; allow 23.61.77.54; allow 23.62.253.54; allow 23.63.141.54; allow 23.64.173.54; allow 23.64.93.54; allow 23.65.13.54; allow 23.65.141.54; allow 23.74.21.54;
The reason that we don't add .conf is so it's not autoloaded by nginx.
Add this line in the vhost(s) that you want the PayPal IPs to be specifically whitelisted.
include /etc/nginx/conf.d/custom-whitelist-paypal-ips-dont-autoload;
Test config
nginx -t
reload nginx config
nginx -s reload