This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
RUN: | |
composer install cloudflare/sdk | |
*/ | |
require_once('vendor/autoload.php'); | |
$domains = array('domain1.com','domain2.com'); | |
$key = new \Cloudflare\API\Auth\APIKey('useremail@email.com', 'ApiKey'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Muestro las URL que se envian al backend | |
varnishtop -i BereqURL | |
# Muestro los host de peticiones al back | |
varnishtop -b -I BeReqHeader:Host | |
# Muestro todas URL peticionadas | |
varnishtop -i requrl | |
# Mostrar peticiones metodo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
DOCS: | |
https://cloud.google.com/storage/docs/access-control/signed-urls | |
https://cloud.google.com/storage/docs/access-control/signing-urls-manually | |
Translate to PHP of code Python: https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/storage/signed_urls/generate_signed_urls.py | |
*/ | |
function generate_signed_url_google($service_account_file, $bucket_name, $object_name, $subresource = null, $expiration=604800, $http_method='GET', $query_parameters = array(), $headers = array()){ | |
date_default_timezone_set('UTC'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## ## Not complete default.vcl code | |
# Install https://github.com/varnish/varnish-modules | |
import vsthrottle; | |
# If I want to implement limitation to any request (do not declare req.http.X-Actual-IP again in other subsequent subroutines) | |
sub vcl_recv { | |
# GET REAL IP USER from proxy CLOUDFLARE | |
set req.http.X-Actual-IP = regsub(req.http.X-Forwarded-For, "[, ].*$", ""); | |
if(vsthrottle.is_denied(req.http.X-Actual-IP, 50, 5s, 60s)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## ## Not complete default.vcl code | |
sub vcl_recv { | |
set req.http.IPCountry = "no-specified"; | |
# usage ISO 3166-1 alpha-2 ( https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 ) | |
## If I want to group BR and US in same group cache | |
if (req.http.CF-IPCountry == "BR" || req.http.CF-IPCountry == "US") { | |
set req.http.IPCountry = "group-br-and-us"; | |
} else { | |
set req.http.IPCountry = req.http.CF-IPCountry; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## ## Not complete default.vcl code | |
# Routine to try and identify device | |
sub identify_device { | |
# Default to thinking it's desktop | |
set req.http.X-UA-Device = "desktop"; | |
if (req.http.User-Agent ~ "iPad" ) { | |
# It says its a iPad - so let's give them the tablet-site | |
set req.http.X-UA-Device = "tablet"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# in vcl_recv | |
if (req.url ~ "(\?|&)(__cf_chl_jschl_tk__)=") { | |
set req.url = regsuball(req.url, "&(__cf_chl_jschl_tk__)=([A-z0-9_\-\.%25]+)", ""); | |
set req.url = regsuball(req.url, "\?(__cf_chl_jschl_tk__)=([A-z0-9_\-\.%25]+)", "?"); | |
set req.url = regsub(req.url, "\?&", "?"); | |
set req.url = regsub(req.url, "\?$", ""); | |
} |