Skip to content

☁💨 Provides a way to retrieve cloudfront proxies ip ranges with caching mechanism

Notifications You must be signed in to change notification settings

tag-walk/cloudfront-trusted-proxies

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cloudfront-trusted-proxies

Provides a way to retrieve cloudfront proxies ip ranges with caching mechanism

Symfony context

The initial purpose of this library is to used in a symfony project. As you can read in the official documentation
If you are using CloudFront on top of your load balancer symfony does not provide an easy way to trust proxies traffic, as it will only trust the node sitting directly above your application (in this case your load balancer). You also need to append the IP addresses or ranges of any additional proxy (in this case CloudFront IP ranges) to the array of trusted proxies.

Usage

// public/index.php

$cache = new FilesystemAdapter('cloudfront_trusted_ips', 3600);
$proxyHelper = new ProxiesHelper($cache);
$trustedProxies = $proxyHelper->list();
Request::setTrustedProxies(
    array_merge(['127.0.0.1', 'REMOTE_ADDR'], $trustedProxies),
    Request::HEADER_X_FORWARDED_AWS_ELB
);

About

☁💨 Provides a way to retrieve cloudfront proxies ip ranges with caching mechanism

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%