Skip to content

Instantly share code, notes, and snippets.

@ceylani
ceylani / nginx_logformat.txt
Created December 2, 2016 08:37
nginx logformat
log_format main '$remote_addr - "$http_x_forwarded_for" - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent "$http_referer" '
'"$http_user_agent"' ;
@ceylani
ceylani / curl_normal_request_example.txt
Created December 2, 2016 08:35
curl normale request example
curl http://aws-lb-adresiniz.elb.amazonaws.com/
@ceylani
ceylani / curl_header_manipulation_example.txt
Created December 2, 2016 08:33
curl header manipulation example
curl -i --header "X-Forwarded-For: 1.1.1.1, 2.2.2.2" http://aws-lb-adresiniz.elb.amazonaws.com/
@ceylani
ceylani / gcloud_lb_real_ip.txt
Last active December 2, 2016 08:31
Getting real IP address from gcloud HTTP LB
function getClientIP()
{
if ($_SERVER['HTTP_X_FORWARDED_FOR']) {
$ip_exp = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
$c = count($ip_exp) - 2;
$real_ip = trim($ip_exp[$c]);
return $_SERVER['REMOTE_ADDR'] = $real_ip;
} else {
return $_SERVER['REMOTE_ADDR'];
}
@ceylani
ceylani / aws_lb_real_ip.txt
Last active December 2, 2016 08:31
Getting real IP address from AWS LB
function getClientIP()
{
if ($_SERVER['HTTP_X_FORWARDED_FOR']) {
$ip_exp = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
$c = count($ip_exp) - 1;
$real_ip = trim($ip_exp[$c]);
return $_SERVER['REMOTE_ADDR'] = $real_ip;
} else {
return $_SERVER['REMOTE_ADDR'];
}