switch_rpath.sh 774 B

12345678910111213141516171819202122232425262728293031323334
  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. # Disabling rpaf
  12. /usr/sbin/a2dismod rpaf > /dev/null 2>&1
  13. rm -f /etc/apache2/mods-enabled/rpaf.conf
  14. # Enabling remoteip
  15. /usr/sbin/a2enmod remoteip > /dev/null 2>&1
  16. # Creating configuration
  17. conf="/etc/apache2/mods-enabled/remoteip.conf"
  18. echo "<IfModule remoteip_module>" > $conf
  19. echo " RemoteIPHeader X-Real-IP" >> $conf
  20. for ip in $(ls /usr/local/vesta/data/ips); do
  21. echo " RemoteIPInternalProxy $ip" >> $conf
  22. done
  23. echo "</IfModule>" >> $conf
  24. # Restarting apache
  25. /usr/sbin/apachectl restart > /dev/null 2>&1
  26. # EOF
  27. exit