-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstallmodremoteip
More file actions
executable file
·63 lines (53 loc) · 1.96 KB
/
installmodremoteip
File metadata and controls
executable file
·63 lines (53 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
# Nginx Admin Installer
# Website: www.nginxcp.com
#
# Copyright (C) NGINXCP.COM.
# Check for EA4
if [ -f /etc/apache2/conf/httpd.conf ]; then
yum -y install ea-apache24-mod_remoteip
REMOTEIPCONF=/etc/apache2/conf.modules.d/$(ls /etc/apache2/conf.modules.d/|grep mod_remoteip)
LIST=$(/scripts/ipusage | awk '{print $1}' | while read ip; do echo -ne "RemoteIPInternalProxy ${ip}\n"; done)
if [ -f $REMOTEIPCONF ]; then
cat > $REMOTEIPCONF <<EOF
LoadModule remoteip_module modules/mod_remoteip.so
#Mod_remoteip settings
RemoteIPHeader X-Real-IP
RemoteIPInternalProxy 127.0.0.1 $LIST
EOF
fi
else
apache_version=`/usr/sbin/httpd -V 2>&1 | sed -n 's/.*Apache\/\(2\.[0-9]*\.[0-9]*\).*/\1/p'`
remoteip_path="/home/cpeasyapache/src/httpd-2.4/modules/metadata"
if [ ! -f "$remoteip_path/mod_remoteip.c" ]
then
echo "RemoteIP module not found at $remoteip_path/mod_remoteip.c"
exit
fi
cd $remoteip_path
/usr/local/apache/bin/apxs -i -c -n mod_remoteip.so mod_remoteip.c
/usr/local/cpanel/bin/apache_conf_distiller --update
/scripts/rebuildhttpdconf
if grep "remoteip.conf" /usr/local/apache/conf/httpd.conf
then
/scripts/rebuildippool > /dev/null 2>&1
LIST=$(/scripts/ipusage | awk '{print $1}' | while read ip; do echo -ne "RemoteIPInternalProxy ${ip}\n"; done)
cat > /usr/local/apache/conf/includes/remoteip.conf << EOF
LoadModule remoteip_module modules/mod_remoteip.so
#Mod_remoteip settings
RemoteIPHeader X-Real-IP
RemoteIPInternalProxy 127.0.0.1 $LIST
EOF
else
/scripts/rebuildippool
LIST=$(/scripts/ipusage | awk '{print $1}' | while read ip; do echo -ne "RemoteIPInternalProxy ${ip}\n"; done)
cat > /usr/local/apache/conf/includes/remoteip.conf << EOF
LoadModule remoteip_module modules/mod_remoteip.so
#Mod_remoteip settings
RemoteIPHeader X-Real-IP
RemoteIPInternalProxy 127.0.0.1 $LIST
EOF
echo "Include \"/usr/local/apache/conf/includes/remoteip.conf\"" >> /usr/local/apache/conf/httpd.conf
fi
/etc/init.d/httpd restart
fi