le1t0-deprec 2.1.6.001
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +444 -0
- data/COPYING +19 -0
- data/LICENSE +339 -0
- data/README +154 -0
- data/THANKS +17 -0
- data/bin/depify +139 -0
- data/docs/EXAMPLE-installing_tracks.txt +41 -0
- data/docs/README.nagios +22 -0
- data/docs/README.rails +17 -0
- data/docs/config_gen_explained.txt +39 -0
- data/docs/deprec-1.x/deprec-1.x.quickstart +50 -0
- data/docs/deprec-1.x/notes.txt +12 -0
- data/docs/old/deprec_banner.gif +0 -0
- data/docs/windows_linux.txt +350 -0
- data/docs/xen/traffic_monitoring_with_vnstat.txt +95 -0
- data/docs/xen/xen-tools-notes.txt +31 -0
- data/docs/xen/xen_on_hardy.txt +39 -0
- data/lib/deprec.rb +42 -0
- data/lib/deprec/capistrano_extensions.rb +446 -0
- data/lib/deprec/recipes.rb +7 -0
- data/lib/deprec/recipes/aoe.rb +79 -0
- data/lib/deprec/recipes/app/mongrel.rb +213 -0
- data/lib/deprec/recipes/app/passenger.rb +190 -0
- data/lib/deprec/recipes/ar_sendmail.rb +67 -0
- data/lib/deprec/recipes/aspell.rb +22 -0
- data/lib/deprec/recipes/canonical.rb +68 -0
- data/lib/deprec/recipes/cap.rb +39 -0
- data/lib/deprec/recipes/chef.rb +68 -0
- data/lib/deprec/recipes/collectd.rb +112 -0
- data/lib/deprec/recipes/db/couchdb.rb +107 -0
- data/lib/deprec/recipes/db/mysql.rb +194 -0
- data/lib/deprec/recipes/db/postgresql.rb +104 -0
- data/lib/deprec/recipes/db/sqlite.rb +37 -0
- data/lib/deprec/recipes/ddclient.rb +51 -0
- data/lib/deprec/recipes/deprec.rb +167 -0
- data/lib/deprec/recipes/deprecated.rb +71 -0
- data/lib/deprec/recipes/drbd.rb +137 -0
- data/lib/deprec/recipes/dummy.rb +22 -0
- data/lib/deprec/recipes/example.rb +115 -0
- data/lib/deprec/recipes/git.rb +97 -0
- data/lib/deprec/recipes/gitosis.rb.disabled +55 -0
- data/lib/deprec/recipes/glusterfs.rb +176 -0
- data/lib/deprec/recipes/god.rb +70 -0
- data/lib/deprec/recipes/haproxy.rb +115 -0
- data/lib/deprec/recipes/heartbeat.rb +138 -0
- data/lib/deprec/recipes/imagemagick/imagemagick_bin.rb +24 -0
- data/lib/deprec/recipes/imagemagick/imagemagick_src.rb +39 -0
- data/lib/deprec/recipes/integrity.rb +108 -0
- data/lib/deprec/recipes/iptables.rb +94 -0
- data/lib/deprec/recipes/java.rb +23 -0
- data/lib/deprec/recipes/keepalived.rb +78 -0
- data/lib/deprec/recipes/ldap.rb +52 -0
- data/lib/deprec/recipes/logrotate.rb +56 -0
- data/lib/deprec/recipes/lvm.rb +20 -0
- data/lib/deprec/recipes/memcache.rb +49 -0
- data/lib/deprec/recipes/mongodb.rb +94 -0
- data/lib/deprec/recipes/monit.rb +135 -0
- data/lib/deprec/recipes/mysql_proxy.rb +67 -0
- data/lib/deprec/recipes/nagios.rb +361 -0
- data/lib/deprec/recipes/network.rb +116 -0
- data/lib/deprec/recipes/ntp.rb +103 -0
- data/lib/deprec/recipes/php.rb +58 -0
- data/lib/deprec/recipes/postfix.rb +115 -0
- data/lib/deprec/recipes/profiles.rb +125 -0
- data/lib/deprec/recipes/raid/amcc_3ware.rb +21 -0
- data/lib/deprec/recipes/rails.rb +330 -0
- data/lib/deprec/recipes/redhat_cluster.rb +228 -0
- data/lib/deprec/recipes/redis.rb +90 -0
- data/lib/deprec/recipes/ruby/mri.rb +55 -0
- data/lib/deprec/recipes/ruby/ree.rb +40 -0
- data/lib/deprec/recipes/rvm.rb +32 -0
- data/lib/deprec/recipes/s3utils.rb +63 -0
- data/lib/deprec/recipes/sphinx/thinking_sphinx.rb +105 -0
- data/lib/deprec/recipes/sphinx/ultrasphinx.rb +86 -0
- data/lib/deprec/recipes/ssh.rb +147 -0
- data/lib/deprec/recipes/ssl.rb +56 -0
- data/lib/deprec/recipes/starling.rb +119 -0
- data/lib/deprec/recipes/svn.rb +171 -0
- data/lib/deprec/recipes/syslog.rb +63 -0
- data/lib/deprec/recipes/trac.rb.disabled +277 -0
- data/lib/deprec/recipes/tsung.rb +74 -0
- data/lib/deprec/recipes/ubuntu.rb +90 -0
- data/lib/deprec/recipes/users.rb +90 -0
- data/lib/deprec/recipes/utils.rb +58 -0
- data/lib/deprec/recipes/vnstat.rb +85 -0
- data/lib/deprec/recipes/web/apache.rb +143 -0
- data/lib/deprec/recipes/web/nginx.rb +172 -0
- data/lib/deprec/recipes/wordpress.rb.notworking +96 -0
- data/lib/deprec/recipes/wpmu.rb +103 -0
- data/lib/deprec/recipes/xen.rb +364 -0
- data/lib/deprec/recipes/xentools.rb +101 -0
- data/lib/deprec/recipes_minus_rails.rb +125 -0
- data/lib/deprec/templates/aoe/aoe-init +55 -0
- data/lib/deprec/templates/aoe/fence_aoemask +351 -0
- data/lib/deprec/templates/apache/namevirtualhosts.conf +5 -0
- data/lib/deprec/templates/apache/ports.conf.erb +5 -0
- data/lib/deprec/templates/apache/status.conf.erb +17 -0
- data/lib/deprec/templates/ar_sendmail/logrotate.conf.erb +9 -0
- data/lib/deprec/templates/ar_sendmail/monit.conf.erb +5 -0
- data/lib/deprec/templates/chef/chef.json.erb +1 -0
- data/lib/deprec/templates/chef/solo.rb +2 -0
- data/lib/deprec/templates/collectd/collectd-init.d +153 -0
- data/lib/deprec/templates/collectd/collectd.conf.erb +686 -0
- data/lib/deprec/templates/ddclient/ddclient.conf.erb +11 -0
- data/lib/deprec/templates/ddclient/ddclient.erb +15 -0
- data/lib/deprec/templates/deprec/caprc.erb +14 -0
- data/lib/deprec/templates/drbd/drbd.conf.erb +531 -0
- data/lib/deprec/templates/glusterfs/glusterfsd-init.erb +95 -0
- data/lib/deprec/templates/gnbd_client/cluster.conf.erb +21 -0
- data/lib/deprec/templates/gnbd_client/clvm-default.erb +3 -0
- data/lib/deprec/templates/gnbd_client/cman-default.erb +6 -0
- data/lib/deprec/templates/gnbd_client/gnbdimports.conf.erb +1 -0
- data/lib/deprec/templates/gnbd_server/cluster.conf.erb +20 -0
- data/lib/deprec/templates/gnbd_server/clvm-default.erb +3 -0
- data/lib/deprec/templates/gnbd_server/cman-default.erb +6 -0
- data/lib/deprec/templates/gnbd_server/gnbd-server-default.erb +1 -0
- data/lib/deprec/templates/gnbd_server/gnbdexports.conf.erb +1 -0
- data/lib/deprec/templates/god/god-conf.erb +2 -0
- data/lib/deprec/templates/god/god-init.erb +47 -0
- data/lib/deprec/templates/haproxy/haproxy-init.d +120 -0
- data/lib/deprec/templates/haproxy/haproxy.cfg.erb +31 -0
- data/lib/deprec/templates/heartbeat/authkeys.erb +2 -0
- data/lib/deprec/templates/heartbeat/ha.cf.erb +15 -0
- data/lib/deprec/templates/heartbeat/haresources.erb +1 -0
- data/lib/deprec/templates/integrity/apache_vhost.erb +4 -0
- data/lib/deprec/templates/integrity/config.ru.erb +21 -0
- data/lib/deprec/templates/integrity/config.yml.erb +43 -0
- data/lib/deprec/templates/iptables/firewall-default.erb +13 -0
- data/lib/deprec/templates/iptables/firewall-init.erb +171 -0
- data/lib/deprec/templates/keepalived/keepalived.conf.erb +18 -0
- data/lib/deprec/templates/logrotate/logrotate.conf.erb +32 -0
- data/lib/deprec/templates/mongodb/mongodb-init.d +88 -0
- data/lib/deprec/templates/mongrel/apache_vhost.conf.erb +148 -0
- data/lib/deprec/templates/mongrel/logrotate.conf.erb +11 -0
- data/lib/deprec/templates/mongrel/mongrel_cluster-init-script +54 -0
- data/lib/deprec/templates/mongrel/mongrel_cluster.yml.erb +10 -0
- data/lib/deprec/templates/mongrel/monit.conf.erb +17 -0
- data/lib/deprec/templates/mongrel/nginx_vhost.conf.erb +41 -0
- data/lib/deprec/templates/monit/monit-init-script +104 -0
- data/lib/deprec/templates/monit/monitrc.erb +250 -0
- data/lib/deprec/templates/monit/nothing.monitrc +0 -0
- data/lib/deprec/templates/mysql/create_databases.sql +20 -0
- data/lib/deprec/templates/mysql/database.yml.prod +6 -0
- data/lib/deprec/templates/mysql/database.yml.stage +6 -0
- data/lib/deprec/templates/mysql/my.cnf.erb +140 -0
- data/lib/deprec/templates/mysql/sphinx.conf.prod +542 -0
- data/lib/deprec/templates/mysql/sphinx.conf.stage +542 -0
- data/lib/deprec/templates/mysql_proxy/mysql-proxy-default.erb +4 -0
- data/lib/deprec/templates/nagios/README +32 -0
- data/lib/deprec/templates/nagios/cgi.cfg.erb +357 -0
- data/lib/deprec/templates/nagios/check_linux_free_memory.pl +118 -0
- data/lib/deprec/templates/nagios/check_mongrel_cluster.rb +82 -0
- data/lib/deprec/templates/nagios/htpasswd.users +1 -0
- data/lib/deprec/templates/nagios/mrtg.cfg +180 -0
- data/lib/deprec/templates/nagios/nagios.cfg.erb +1325 -0
- data/lib/deprec/templates/nagios/nrpe.cfg.erb +222 -0
- data/lib/deprec/templates/nagios/nrpe.xinetd.erb +16 -0
- data/lib/deprec/templates/nagios/objects/commands.cfg.erb +265 -0
- data/lib/deprec/templates/nagios/objects/contacts.cfg.erb +89 -0
- data/lib/deprec/templates/nagios/objects/hosts.cfg.erb +114 -0
- data/lib/deprec/templates/nagios/objects/localhost.cfg.erb +116 -0
- data/lib/deprec/templates/nagios/objects/services.cfg.erb +165 -0
- data/lib/deprec/templates/nagios/objects/timeperiods.cfg.erb +94 -0
- data/lib/deprec/templates/nagios/resource.cfg.erb +34 -0
- data/lib/deprec/templates/network/hostname.erb +1 -0
- data/lib/deprec/templates/network/hosts.erb +2 -0
- data/lib/deprec/templates/network/interfaces.erb +18 -0
- data/lib/deprec/templates/network/resolv.conf.erb +6 -0
- data/lib/deprec/templates/nginx/logrotate.conf.erb +13 -0
- data/lib/deprec/templates/nginx/mime.types.erb +70 -0
- data/lib/deprec/templates/nginx/nginx-init-script +62 -0
- data/lib/deprec/templates/nginx/nginx.conf.erb +125 -0
- data/lib/deprec/templates/nginx/nginx.logrotate.d +12 -0
- data/lib/deprec/templates/nginx/nothing.conf +1 -0
- data/lib/deprec/templates/nginx/rails_nginx_vhost.conf.erb +41 -0
- data/lib/deprec/templates/ntp/ntp.conf.erb +42 -0
- data/lib/deprec/templates/passenger/apache_vhost.erb +29 -0
- data/lib/deprec/templates/passenger/logrotate.conf.erb +12 -0
- data/lib/deprec/templates/passenger/passenger.conf.erb +21 -0
- data/lib/deprec/templates/passenger/passenger.load.erb +3 -0
- data/lib/deprec/templates/postfix/aliases.erb +3 -0
- data/lib/deprec/templates/postfix/dynamicmaps.cf.erb +8 -0
- data/lib/deprec/templates/postfix/main.cf.erb +36 -0
- data/lib/deprec/templates/postfix/master.cf.erb +77 -0
- data/lib/deprec/templates/redis/redis-conf.erb +132 -0
- data/lib/deprec/templates/redis/redis-init.erb +50 -0
- data/lib/deprec/templates/s3utils/s3cfg +35 -0
- data/lib/deprec/templates/s3utils/s3config.yml +3 -0
- data/lib/deprec/templates/sphinx/monit.conf.erb +5 -0
- data/lib/deprec/templates/ssh/ssh_config.erb +50 -0
- data/lib/deprec/templates/ssh/sshd_config.erb +78 -0
- data/lib/deprec/templates/ssl/make-ssl-cert +138 -0
- data/lib/deprec/templates/ssl/ssl-cert-snakeoil.key +15 -0
- data/lib/deprec/templates/ssl/ssl-cert-snakeoil.pem +19 -0
- data/lib/deprec/templates/starling/monit.conf.erb +14 -0
- data/lib/deprec/templates/starling/starling-init-script.erb +71 -0
- data/lib/deprec/templates/subversion/svn.apache.vhost.erb +43 -0
- data/lib/deprec/templates/syslog/syslog.conf.erb +71 -0
- data/lib/deprec/templates/syslog/syslogd.erb +13 -0
- data/lib/deprec/templates/trac/apache_vhost.conf.erb +24 -0
- data/lib/deprec/templates/trac/nginx_vhost.conf.erb +26 -0
- data/lib/deprec/templates/trac/trac.ini.erb +169 -0
- data/lib/deprec/templates/trac/trac_deprec.png +0 -0
- data/lib/deprec/templates/trac/tracd-init.erb +43 -0
- data/lib/deprec/templates/trac/users.htdigest.erb +0 -0
- data/lib/deprec/templates/tsung/tsung.xml.erb +47 -0
- data/lib/deprec/templates/vnstat/config.php +57 -0
- data/lib/deprec/templates/wordpress/apache2_wordpress_vhost.conf.erb +31 -0
- data/lib/deprec/templates/wordpress/wp-config.php.erb +31 -0
- data/lib/deprec/templates/wpmu/apache_vhost.conf.erb +13 -0
- data/lib/deprec/templates/xen/network-bridge-wrapper +3 -0
- data/lib/deprec/templates/xen/xend-config.sxp.erb +195 -0
- data/lib/deprec/templates/xen/xend-init.erb +57 -0
- data/lib/deprec/templates/xen/xendomains.erb +137 -0
- data/lib/deprec/templates/xentools/100-ubuntu-setup +26 -0
- data/lib/deprec/templates/xentools/15-disable-hwclock +40 -0
- data/lib/deprec/templates/xentools/30-disable-gettys +57 -0
- data/lib/deprec/templates/xentools/31-ubuntu-setup +32 -0
- data/lib/deprec/templates/xentools/40-setup-networking +145 -0
- data/lib/deprec/templates/xentools/98-custom +17 -0
- data/lib/deprec/templates/xentools/xen-tools.conf.erb +278 -0
- data/lib/deprec/templates/xentools/xm.tmpl.erb +138 -0
- data/lib/deprec_cmd_completion.sh +26 -0
- data/lib/deprec_minus_rails.rb +12 -0
- data/lib/vmbuilder_plugins/all.rb +20 -0
- data/lib/vmbuilder_plugins/apt.rb +93 -0
- data/lib/vmbuilder_plugins/emerge.rb +76 -0
- data/lib/vmbuilder_plugins/gem.rb +100 -0
- data/lib/vmbuilder_plugins/std.rb +203 -0
- metadata +304 -0
@@ -0,0 +1,13 @@
|
|
1
|
+
# define tcp ports allowed for the world: "tcp:80,443"
|
2
|
+
# define non-tcp/udp/icmp protocols allowed for the world: "pptp"
|
3
|
+
# define tcp/udp ports allowed for specific networks/IPs: "tcp:389;udp:514@10.0.1.2,192.168.0.0/24 tcp,udp:22@192.168.0.3"
|
4
|
+
# define non-tcp/udp/icmp protocols allowed for specific networks/IPs: "vrrp@192.168.0.0/24"
|
5
|
+
# example: allowed="tcp:80,443 udp:138 pptp tcp:21,443@192.168.0.0/24 tcp:389;udp:514@10.0.1.2,10.0.1.5 vrrp@192.168.0.0/24 gre@10.0.1.2"
|
6
|
+
allowed="<%= iptables_allowed %>"
|
7
|
+
|
8
|
+
# example: forwards="192.168.0.1:8080>192.168.0.2:80;tcp 192.168.0.1:514>192.168.0.2:514;udp"
|
9
|
+
forwards="<%= iptables_forwards %>"
|
10
|
+
|
11
|
+
DRYRUN="NO" # Set to exactly YES to enable dry runs
|
12
|
+
IPTABLES="<%= iptables_binary %>"
|
13
|
+
IPTABLES_SAVE="<%= iptables_save_binary %>"
|
@@ -0,0 +1,171 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
# Copyright 2009-2010 by le1t0@github. All rights reserved.
|
3
|
+
|
4
|
+
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:/usr/local/sbin
|
5
|
+
DRYRUN="NO" # Set to exactly YES to enable dry runs
|
6
|
+
IPTABLES="/sbin/iptables"
|
7
|
+
IPTABLES_SAVE="/sbin/iptables-save"
|
8
|
+
ENABLED=1
|
9
|
+
|
10
|
+
test -x $IPTABLES || exit 0
|
11
|
+
|
12
|
+
if [ -e /etc/default/firewall ]; then
|
13
|
+
. /etc/default/firewall
|
14
|
+
fi
|
15
|
+
|
16
|
+
test "$ENABLED" != "0" || exit 0
|
17
|
+
|
18
|
+
if [ "$DRYRUN" = "YES" ] ; then
|
19
|
+
IPTABLES="echo ${IPTABLES}"
|
20
|
+
fi
|
21
|
+
|
22
|
+
[ -f /etc/default/rcS ] && . /etc/default/rcS
|
23
|
+
. /lib/lsb/init-functions
|
24
|
+
|
25
|
+
function flush_rules () {
|
26
|
+
if [ -x $IPTABLES_SAVE ]; then
|
27
|
+
tmpfile="/tmp/.firewall.save.$(date +"%Y%m%d%H%M%S").tmp"
|
28
|
+
# save current firewall FORWARD rules with physdev-in, these are necessary for the functioning of xen
|
29
|
+
$IPTABLES_SAVE -t filter | perl -ne "m/^-A FORWARD/ && m/physdev-in/ && print \"${IPTABLES} \" . \$_" > $tmpfile
|
30
|
+
fi
|
31
|
+
# flush default chains
|
32
|
+
$IPTABLES -F -t nat
|
33
|
+
$IPTABLES -F
|
34
|
+
# delete all custom chains
|
35
|
+
$IPTABLES -X
|
36
|
+
# source, re-apply and remove saved rules of above
|
37
|
+
if [ -x $IPTABLES_SAVE ]; then
|
38
|
+
. $tmpfile
|
39
|
+
rm -f $tmpfile
|
40
|
+
fi
|
41
|
+
}
|
42
|
+
|
43
|
+
function define_forwards () {
|
44
|
+
for forward in $forwards ; do {
|
45
|
+
proto="$(echo $forward | cut -d ';' -f 2)"
|
46
|
+
localip="$(echo $forward | cut -d '>' -f 1 | cut -d ':' -f 1)"
|
47
|
+
srcport="$(echo $forward | cut -d '>' -f 1 | cut -d ':' -f 2)"
|
48
|
+
destip="$(echo $forward | cut -d ';' -f 1 | cut -d '>' -f '2' | cut -d ':' -f 1)"
|
49
|
+
destport="$(echo $forward | cut -d ';' -f 1 | cut -d '>' -f '2' | cut -d ':' -f 2)"
|
50
|
+
$IPTABLES -t nat -A PREROUTING -p $proto -d $localip --dport $srcport -j DNAT --to $destip:$destport
|
51
|
+
$IPTABLES -A FORWARD -p $proto -d $destip --dport $destport -j ACCEPT
|
52
|
+
} ; done
|
53
|
+
}
|
54
|
+
|
55
|
+
function set_default_policies () {
|
56
|
+
$IPTABLES --policy INPUT $1
|
57
|
+
$IPTABLES --policy OUTPUT $2
|
58
|
+
$IPTABLES --policy FORWARD $3
|
59
|
+
}
|
60
|
+
|
61
|
+
function set_default_rules () {
|
62
|
+
# Allow unlimited traffic on the loopback interface
|
63
|
+
$IPTABLES -A INPUT -i lo -j ACCEPT
|
64
|
+
$IPTABLES -A OUTPUT -o lo -j ACCEPT
|
65
|
+
|
66
|
+
# Previously initiated and accepted exchanges bypass rule checking
|
67
|
+
$IPTABLES -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
|
68
|
+
# Allow unlimited outbound traffic
|
69
|
+
$IPTABLES -A OUTPUT -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
|
70
|
+
}
|
71
|
+
|
72
|
+
# don't call parse_sources directly! It's called by set_allowed_rules
|
73
|
+
function parse_sources () {
|
74
|
+
for sourcedef in $1 ; do {
|
75
|
+
parse_targets "$2" "-s ${sourcedef}"
|
76
|
+
} ; done
|
77
|
+
}
|
78
|
+
|
79
|
+
# don't call parse_targets directly! It's called by set_allowed_rules
|
80
|
+
function parse_targets () {
|
81
|
+
sourcedef="$2"
|
82
|
+
for targetdef in $1 ; do {
|
83
|
+
protocols="$(echo $targetdef | awk -F ":" '{ print $1; }' | sed 's/,/ /g')"
|
84
|
+
ports="$(echo $targetdef | awk -F ":" '{ print $2; }' | sed 's/,/ /g')"
|
85
|
+
for protocol in ${protocols} ; do {
|
86
|
+
if [ -z "${ports}" ] ; then
|
87
|
+
$IPTABLES -A INPUT -p ${protocol} ${sourcedef} -m state --state NEW -j ACCEPT ;
|
88
|
+
else
|
89
|
+
for port in ${ports} ; do {
|
90
|
+
OPT="--dport"
|
91
|
+
[ "$protocol" = "icmp" ] && OPT="--icmp-type"
|
92
|
+
$IPTABLES -A INPUT -p ${protocol} ${sourcedef} -m state --state NEW $OPT ${port} -j ACCEPT ;
|
93
|
+
} ; done
|
94
|
+
fi
|
95
|
+
} ; done
|
96
|
+
} ; done
|
97
|
+
}
|
98
|
+
|
99
|
+
function set_allowed_rules () {
|
100
|
+
for ruledef in ${allowed} ; do {
|
101
|
+
target="$(echo $ruledef | awk -F "@" '{ print $1; }' | sed 's/;/ /g')"
|
102
|
+
source="$(echo $ruledef | awk -F "@" '{ print $2; }' | sed 's/,/ /g')"
|
103
|
+
if [ -z "${source}" ] ; then
|
104
|
+
parse_targets "$target"
|
105
|
+
else
|
106
|
+
parse_sources "$source" "$target"
|
107
|
+
fi
|
108
|
+
} ; done
|
109
|
+
}
|
110
|
+
|
111
|
+
function set_proc_variables () {
|
112
|
+
# Kernel monitoring support
|
113
|
+
# More information:
|
114
|
+
# /usr/src/linux-`uname -r`/Documentation/networking/ip-sysctl.txt
|
115
|
+
# http://www.linuxgazette.com/book/view/1645
|
116
|
+
# http://www.spirit.com/Network/net0300.html
|
117
|
+
|
118
|
+
# Drop ICMP echo-request messages sent to broadcast or multicast addresses
|
119
|
+
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
|
120
|
+
|
121
|
+
# Drop source routed packets
|
122
|
+
echo 0 > /proc/sys/net/ipv4/conf/all/accept_source_route
|
123
|
+
|
124
|
+
# Enable TCP SYN cookie protection from SYN floods
|
125
|
+
echo 1 > /proc/sys/net/ipv4/tcp_syncookies
|
126
|
+
|
127
|
+
# Don't accept ICMP redirect messages
|
128
|
+
echo 0 > /proc/sys/net/ipv4/conf/all/accept_redirects
|
129
|
+
|
130
|
+
# Don't send ICMP redirect messages
|
131
|
+
echo 0 > /proc/sys/net/ipv4/conf/all/send_redirects
|
132
|
+
|
133
|
+
# Enable source address spoofing protection
|
134
|
+
echo 1 > /proc/sys/net/ipv4/conf/all/rp_filter
|
135
|
+
|
136
|
+
# Log packets with impossible source addresses
|
137
|
+
echo 1 > /proc/sys/net/ipv4/conf/all/log_martians
|
138
|
+
}
|
139
|
+
|
140
|
+
function firewall_start () {
|
141
|
+
set_proc_variables
|
142
|
+
flush_rules
|
143
|
+
set_default_policies DROP ACCEPT ACCEPT
|
144
|
+
define_forwards
|
145
|
+
set_default_rules
|
146
|
+
set_allowed_rules
|
147
|
+
}
|
148
|
+
|
149
|
+
function firewall_stop () {
|
150
|
+
flush_rules
|
151
|
+
set_default_policies ACCEPT ACCEPT ACCEPT
|
152
|
+
}
|
153
|
+
|
154
|
+
case "$1" in
|
155
|
+
start)
|
156
|
+
firewall_start
|
157
|
+
;;
|
158
|
+
stop)
|
159
|
+
firewall_stop
|
160
|
+
;;
|
161
|
+
reload|force-reload)
|
162
|
+
firewall_start
|
163
|
+
;;
|
164
|
+
restart)
|
165
|
+
firewall_start
|
166
|
+
;;
|
167
|
+
*)
|
168
|
+
echo "Usage: /etc/init.d/firewall {start|stop|reload|restart}"
|
169
|
+
exit 3
|
170
|
+
;;
|
171
|
+
esac
|
@@ -0,0 +1,18 @@
|
|
1
|
+
vrrp_script chk_haproxy { # Requires keepalived-1.1.13
|
2
|
+
script "<%= keepalived_script %>" # cheaper than pidof
|
3
|
+
interval <%= keepalived_interval %> # check every 2 seconds
|
4
|
+
weight <%= keepalived_weight %> # add 2 points of prio if OK
|
5
|
+
}
|
6
|
+
|
7
|
+
vrrp_instance VI_1 {
|
8
|
+
interface <%= keepalived_interface %>
|
9
|
+
state <%= keepalived_state %>
|
10
|
+
virtual_router_id <%= keepalived_virtual_router_id %>
|
11
|
+
priority <%= keepalived_priority %>
|
12
|
+
virtual_ipaddress {
|
13
|
+
<%= keepalived_virtual_ipaddress %>
|
14
|
+
}
|
15
|
+
track_script {
|
16
|
+
chk_haproxy
|
17
|
+
}
|
18
|
+
}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# see "man logrotate" for details
|
2
|
+
# rotate log files weekly
|
3
|
+
weekly
|
4
|
+
|
5
|
+
# keep 4 weeks worth of backlogs
|
6
|
+
rotate 4
|
7
|
+
|
8
|
+
# create new (empty) log files after rotating old ones
|
9
|
+
create
|
10
|
+
|
11
|
+
# uncomment this if you want your log files compressed
|
12
|
+
#compress
|
13
|
+
|
14
|
+
# packages drop log rotation information into this directory
|
15
|
+
include /etc/logrotate.d
|
16
|
+
|
17
|
+
# no packages own wtmp, or btmp -- we'll rotate them here
|
18
|
+
/var/log/wtmp {
|
19
|
+
missingok
|
20
|
+
monthly
|
21
|
+
create 0664 root utmp
|
22
|
+
rotate 1
|
23
|
+
}
|
24
|
+
|
25
|
+
/var/log/btmp {
|
26
|
+
missingok
|
27
|
+
monthly
|
28
|
+
create 0664 root utmp
|
29
|
+
rotate 1
|
30
|
+
}
|
31
|
+
|
32
|
+
# system-specific logs may be configured here
|
@@ -0,0 +1,88 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
PATH=/sbin:/usr/sbin:/bin:/usr/bin
|
3
|
+
MONGOD=/usr/local/mongo/bin/mongod
|
4
|
+
DATADIR=/var/lib/mongodb
|
5
|
+
PIDFILE=$DATADIR/mongod.lock
|
6
|
+
LOGFILE=/var/log/mongodb.log
|
7
|
+
EXTRAOPTS=
|
8
|
+
ENABLED=1
|
9
|
+
|
10
|
+
test -x $MONGOD || exit 0
|
11
|
+
|
12
|
+
if [ -e /etc/default/mongodb ]; then
|
13
|
+
. /etc/default/mongodb
|
14
|
+
fi
|
15
|
+
|
16
|
+
test "$ENABLED" != "0" || exit 0
|
17
|
+
|
18
|
+
[ -f /etc/default/rcS ] && . /etc/default/rcS
|
19
|
+
. /lib/lsb/init-functions
|
20
|
+
|
21
|
+
|
22
|
+
mongodb_start()
|
23
|
+
{
|
24
|
+
start-stop-daemon --start --pidfile "$PIDFILE" \
|
25
|
+
--exec $MONGOD -- --fork --logpath $LOGFILE --logappend --dbpath $DATADIR \
|
26
|
+
$EXTRAOPTS || return 2
|
27
|
+
return 0
|
28
|
+
}
|
29
|
+
|
30
|
+
mongodb_stop()
|
31
|
+
{
|
32
|
+
start-stop-daemon --stop --user root --pidfile "$PIDFILE" \
|
33
|
+
|| return 2
|
34
|
+
return 0
|
35
|
+
}
|
36
|
+
|
37
|
+
case "$1" in
|
38
|
+
start)
|
39
|
+
log_daemon_msg "Starting mongodb" "mongodb"
|
40
|
+
mongodb_start
|
41
|
+
case "$?" in
|
42
|
+
0)
|
43
|
+
log_end_msg 0
|
44
|
+
;;
|
45
|
+
1)
|
46
|
+
log_end_msg 1
|
47
|
+
echo "pid file '$PIDFILE' found, mongodb not started."
|
48
|
+
;;
|
49
|
+
2)
|
50
|
+
log_end_msg 1
|
51
|
+
;;
|
52
|
+
esac
|
53
|
+
;;
|
54
|
+
stop)
|
55
|
+
log_daemon_msg "Stopping mongodb" "mongodb"
|
56
|
+
mongodb_stop
|
57
|
+
case "$?" in
|
58
|
+
0|1)
|
59
|
+
log_end_msg 0
|
60
|
+
;;
|
61
|
+
2)
|
62
|
+
log_end_msg 1
|
63
|
+
;;
|
64
|
+
esac
|
65
|
+
;;
|
66
|
+
restart)
|
67
|
+
log_daemon_msg "Restarting mongodb" "mongodb"
|
68
|
+
mongodb_stop
|
69
|
+
mongodb_start
|
70
|
+
case "$?" in
|
71
|
+
0)
|
72
|
+
log_end_msg 0
|
73
|
+
;;
|
74
|
+
1)
|
75
|
+
log_end_msg 1
|
76
|
+
;;
|
77
|
+
2)
|
78
|
+
log_end_msg 1
|
79
|
+
;;
|
80
|
+
esac
|
81
|
+
;;
|
82
|
+
*)
|
83
|
+
echo "Usage: /etc/init.d/mongodb {start|stop|restart}"
|
84
|
+
exit 3
|
85
|
+
;;
|
86
|
+
esac
|
87
|
+
|
88
|
+
:
|
@@ -0,0 +1,148 @@
|
|
1
|
+
<VirtualHost *:80>
|
2
|
+
ServerName <%= domain %>
|
3
|
+
<%- 4.times do |counter| -%>
|
4
|
+
ServerAlias <%= domain.sub(/.*?\./, "assets#{counter}.") %>
|
5
|
+
<%- end %>
|
6
|
+
DocumentRoot <%= "#{current_path}/public" %>
|
7
|
+
ErrorLog <%= apache_log_dir %>/<%= domain %>-error_log
|
8
|
+
CustomLog <%= apache_log_dir %>/<%= domain %>-access_log combined
|
9
|
+
|
10
|
+
<Directory <%= "#{current_path}/public" %>>
|
11
|
+
Options FollowSymLinks
|
12
|
+
AllowOverride None
|
13
|
+
Order allow,deny
|
14
|
+
Allow from all
|
15
|
+
</Directory>
|
16
|
+
|
17
|
+
<Proxy *>
|
18
|
+
Order deny,allow
|
19
|
+
Allow from all
|
20
|
+
</Proxy>
|
21
|
+
|
22
|
+
# Configure mongrel_cluster
|
23
|
+
<Proxy balancer://<%= "#{application}_cluster" %>>
|
24
|
+
<%- mongrel_servers.times do |counter| -%>
|
25
|
+
BalancerMember http://<%= "127.0.0.1:#{mongrel_port+counter}" %>
|
26
|
+
<%- end -%>
|
27
|
+
</Proxy>
|
28
|
+
|
29
|
+
RewriteEngine On
|
30
|
+
|
31
|
+
<%- if apache_ssl_enabled && apache_ssl_forward_all -%>
|
32
|
+
RewriteRule ^(.*)$ https://<%= domain %>$1
|
33
|
+
<%- else -%>
|
34
|
+
# Prevent access to .svn directories
|
35
|
+
RewriteRule ^(.*/)?\.svn/ - [F,L]
|
36
|
+
ErrorDocument 403 "Access Forbidden"
|
37
|
+
|
38
|
+
# Check for maintenance file and redirect all requests
|
39
|
+
RewriteCond %{REQUEST_URI} !\.(css|jpg|png|gif)$
|
40
|
+
RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
|
41
|
+
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
|
42
|
+
RewriteRule ^.*$ /system/maintenance.html [L]
|
43
|
+
|
44
|
+
# Rewrite index to check for static
|
45
|
+
RewriteRule ^/$ /index.html [QSA]
|
46
|
+
|
47
|
+
# Rewrite to check for Rails cached page
|
48
|
+
RewriteRule ^([^.]+)$ $1.html [QSA]
|
49
|
+
|
50
|
+
# Redirect all non-static requests to cluster
|
51
|
+
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
|
52
|
+
RewriteRule ^/(.*)$ balancer://<%= "#{application}_cluster" %>%{REQUEST_URI} [P,QSA,L]
|
53
|
+
|
54
|
+
# Deflate
|
55
|
+
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/x-javascript
|
56
|
+
BrowserMatch ^Mozilla/4 gzip-only-text/html
|
57
|
+
BrowserMatch ^Mozilla/4\.0[678] no-gzip
|
58
|
+
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
|
59
|
+
<%- end -%>
|
60
|
+
</VirtualHost>
|
61
|
+
|
62
|
+
|
63
|
+
<% if apache_ssl_enabled %>
|
64
|
+
<VirtualHost <%= apache_ssl_ip ? apache_ssl_ip : '*' %>:443>
|
65
|
+
ServerName <%= domain %>
|
66
|
+
<%- 4.times do |counter| -%>
|
67
|
+
ServerAlias <%= domain.sub(/.*?\./, "assets#{counter}.") %>
|
68
|
+
<%- end %>
|
69
|
+
DocumentRoot <%= "#{current_path}/public" %>
|
70
|
+
ErrorLog <%= apache_log_dir %>/<%= domain %>-error_log
|
71
|
+
CustomLog <%= apache_log_dir %>/<%= domain %>-access_log combined
|
72
|
+
CustomLog <%= apache_log_dir %>/<%= domain %>-ssl_log \
|
73
|
+
"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
|
74
|
+
|
75
|
+
<Directory <%= "#{current_path}/public" %>>
|
76
|
+
Options FollowSymLinks
|
77
|
+
AllowOverride None
|
78
|
+
Order allow,deny
|
79
|
+
Allow from all
|
80
|
+
</Directory>
|
81
|
+
|
82
|
+
<Proxy *>
|
83
|
+
Order deny,allow
|
84
|
+
Allow from all
|
85
|
+
</Proxy>
|
86
|
+
|
87
|
+
# Configure mongrel_cluster
|
88
|
+
<Proxy balancer://<%= "#{application}_cluster" %>>
|
89
|
+
<%- mongrel_servers.times do |counter| -%>
|
90
|
+
BalancerMember http://<%= "127.0.0.1:#{mongrel_port+counter}" %>
|
91
|
+
<%- end -%>
|
92
|
+
</Proxy>
|
93
|
+
|
94
|
+
RewriteEngine On
|
95
|
+
|
96
|
+
# Prevent access to .svn directories
|
97
|
+
RewriteRule ^(.*/)?\.svn/ - [F,L]
|
98
|
+
ErrorDocument 403 "Access Forbidden"
|
99
|
+
|
100
|
+
# Prevent access to .git directories
|
101
|
+
RewriteRule ^(.*/)?\.git/ - [F,L]
|
102
|
+
ErrorDocument 403 "Access Forbidden"
|
103
|
+
|
104
|
+
# Check for maintenance file and redirect all requests
|
105
|
+
RewriteCond %{REQUEST_URI} !\.(css|jpg|png|gif)$
|
106
|
+
RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
|
107
|
+
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
|
108
|
+
RewriteRule ^.*$ /system/maintenance.html [L]
|
109
|
+
|
110
|
+
# Rewrite index to check for static
|
111
|
+
RewriteRule ^/$ /index.html [QSA]
|
112
|
+
|
113
|
+
# Rewrite to check for Rails cached page
|
114
|
+
RewriteRule ^([^.]+)$ $1.html [QSA]
|
115
|
+
|
116
|
+
# Redirect all non-static requests to cluster
|
117
|
+
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
|
118
|
+
# Add header for Mongrel to set HTTPS environment for Rails
|
119
|
+
RequestHeader set X-Forwarded-Proto "https"
|
120
|
+
RewriteRule ^/(.*)$ balancer://<%= "#{application}_cluster" %>%{REQUEST_URI} [P,QSA,L]
|
121
|
+
|
122
|
+
# Deflate
|
123
|
+
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/x-javascript
|
124
|
+
BrowserMatch ^Mozilla/4 gzip-only-text/html
|
125
|
+
BrowserMatch ^Mozilla/4\.0[678] no-gzip
|
126
|
+
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
|
127
|
+
|
128
|
+
# SSL Engine Switch
|
129
|
+
SSLEngine on
|
130
|
+
|
131
|
+
# SSL Cipher Suite:
|
132
|
+
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
|
133
|
+
|
134
|
+
# Server Certificate
|
135
|
+
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
|
136
|
+
|
137
|
+
# Server Private Key
|
138
|
+
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
|
139
|
+
|
140
|
+
<% if apache_ssl_chainfile %>
|
141
|
+
# Intermediate keys
|
142
|
+
SSLCertificateChainFile /usr/local/apache2/conf/ssl.crt/<%= domain %>-chainfile.crt
|
143
|
+
<% end %>
|
144
|
+
|
145
|
+
BrowserMatch ".*MSIE.*" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0
|
146
|
+
|
147
|
+
</VirtualHost>
|
148
|
+
<% end %>
|