Last active
December 19, 2015 11:38
-
-
Save openprojdev/5948608 to your computer and use it in GitHub Desktop.
Identify apache2 web server serving http requests from frontend by investigating the response http headers, were the web servers are under an load balancer. Example Response header should contain, were 30.10 are the last 2 digits of the web server internal IP address like 192.168.30.10:
X-Fry : "30:10"
This file contains hidden or 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
| #!/bin/sh | |
| # Only publish the last 2 digits of an IP address, do not expose the complete network range | |
| # place this script post testing some were like /etc/rc.local, were issues like dynamic address, or cloned machines in cloud env will have an updated IP address in http header | |
| # This script should run before http starts, experiment to get it right. | |
| # Configuration section | |
| network_id='192.168' # first 2 digits of the IP address identifying the network, usually would be an private ip address reange. | |
| partial_ip_address=`ifconfig | grep 'inet addr:' | grep $network_id | awk -F: '{print $2}' | awk '{print $1}' | awk -F. '{print $3"."$4}'` | |
| apache_conf_file='/etc/apache2/conf.d/X-fry' # RHEL/CentOS could be /etc/http/conf.d/X-fry | |
| echo '<IfModule mod_headers.c>' > $apache_conf_file | |
| echo " Header add X-Fry \"$partial_ip_address\"" >> $apache_conf_file | |
| echo '</IfModule>' >> $apache_conf_file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment