Skip to content

Instantly share code, notes, and snippets.

@openprojdev
Last active December 19, 2015 11:38
Show Gist options
  • Save openprojdev/5948608 to your computer and use it in GitHub Desktop.
Save openprojdev/5948608 to your computer and use it in GitHub Desktop.

Revisions

  1. openprojdev revised this gist Jul 8, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@
    # 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.
    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

  2. openprojdev created this gist Jul 8, 2013.
    13 changes: 13 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    #!/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