switch_rpath.sh 956 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/bin/bash
  2. # Switch apache to remoteip module
  3. # Checking rpaf config
  4. if [ ! -e "/etc/apache2/mods-enabled/rpaf.load" ]; then
  5. exit
  6. fi
  7. # Checking remoteip module
  8. if [ ! -e "/etc/apache2/mods-available/remoteip.load" ]; then
  9. exit
  10. fi
  11. if [ -f "/etc/apache2/mods-enabled/remoteip.load" ]; then
  12. echo "RemoteIP is already activated"
  13. exit
  14. fi
  15. # Disabling rpaf
  16. /usr/sbin/a2dismod rpaf > /dev/null 2>&1
  17. rm -f /etc/apache2/mods-enabled/rpaf.conf
  18. # Enabling remoteip
  19. /usr/sbin/a2enmod remoteip > /dev/null 2>&1
  20. # Creating configuration
  21. conf="/etc/apache2/mods-enabled/remoteip.conf"
  22. echo "<IfModule remoteip_module>" > $conf
  23. echo " RemoteIPHeader X-Real-IP" >> $conf
  24. for ip in $(ls /usr/local/vesta/data/ips); do
  25. echo " RemoteIPInternalProxy $ip" >> $conf
  26. done
  27. echo "</IfModule>" >> $conf
  28. sed -i "s/LogFormat \"%h/LogFormat \"%a/g" /etc/apache2/apache2.conf
  29. # Restarting apache
  30. /usr/sbin/apachectl restart > /dev/null 2>&1
  31. # EOF
  32. exit