Tag Archives: aws

Get the right IP

Get the right IP

Was currently taking part in moving a WordPress site with a single webserver into a AWS Virtual Private cloud using an ELB to loadbalance multiple webservers.  Ran into an issue where IPs were not being grabbed properly and provided to the WordPress control panel for comment moderation.  I have already enabled the X-FORWARDED-FOR header in apache and wanted WordPress to capture this rather than the VPC IPs.

 

https://www.benjaminwiedmann.net/wordpress-behind-reverse-proxy-fix-wrong-ip-insert-x-forwarded-for-ip.html

Placing the following in my wp-config.php made it possible to get the real IP via this header so we can better moderate without requiring registration.  It’s a hack, but it’s a useful one.

// ** bw 2012-08-12 wordpress reverse proxy x-forwarded-for ip fix ** //
if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
  $xffaddrs = explode(',',$_SERVER['HTTP_X_FORWARDED_FOR']);
  $_SERVER['REMOTE_ADDR'] = $xffaddrs[0];
 }
Advertisements
Tagged , ,

get all of your ELB names for some sort of reason

so tony says i need to blog that shit.  so i am blogging that shit.

sometimes when i need to make a large amount of changes to several ELB’s i need a quick way to throw all of the names into a single file.  here’s a fast way to use the AWS API CLI tools to grab all of your ELB names.

prereq:  actual CLI access, your keypair (use dialt0ne’s aks to switch between your IAM accounts), the ELB CLI tools and a few minutes.

Put that shit into a text file:

$ elb-describe-lbs > elbs

cat that shit and pipe into awk printing only the second field which contains the actual ELB names:

$ cat elbs| awk '{print $2}' > elb-names

now look at that shit and confirm you got all your ELBs

$ cat elb-names
that-shit-01
that-shit-02
that-shit-03

now go listen to slayer.

[youtube http://www.youtube.com/watch?v=rvuO2EvCTAE%5D
Tagged , , , ,
Advertisements