Mod proxy ajp

From UFP-UV Sakai Wiki

Jump to: navigation, search

Contents


Apache

/etc/httpd/conf/extra/httpd-modproxy.conf

# Proxy exclusions
ProxyPass /server-status !
ProxyPass /balancer-manager !
ProxyPass /public_ufp !
ProxyPass /sakai-patches !
ProxyPass /doc !
ProxyPass /stats !
ProxyPass /old-stats !
ProxyPass /wiki !
ProxyPass /faq !
ProxyPass /mantis !
ProxyPass /mockups !
ProxyPass ^/favicon\.ico$ !
ProxyPass /library !
ProxyPass /portal/styles !
ProxyPass /portal/scripts !
ProxyPass /tiny_mce !
ProxyPass /jforum-images !
ProxyPass /error-pages !
ProxyPass /unavailable !
ProxyPass /unavailable.php !
ProxyPass /inqueritos !
 
# Proxy load balanced requests between tomcat instances
ProxyPass / balancer://sakaiCluster/ stickysession=JSESSIONID nofailover=Off maxattempts=5 timeout=30
<Proxy balancer://sakaiCluster>
        # MAIN SAKAI
        BalancerMember ajp://localhost:8009 loadfactor=100 route=elearning-a
 
        # HOT STANDBY SAKAI (failure only)
        #BalancerMember ajp://10.11.100.162:10009 route=elearning-c status=+H
 
        # FLAGS to force redirection: redirect=elearning-d status=D
</Proxy>
 
 
# Show Proxy LoadBalancer status in mod_status
ProxyStatus On


Tomcat

Tomcat server.xml

Parameter Tomcat A Tomcat B Tomcat C Tomcat D
Server ID

(used in mod_proxy configuration above and "jvmRoute" in tomcat/conf/server.xml)

elearning-a elearning-b elearning-c elearning-d
Server IP 10.1.1.154 10.1.1.154 10.1.1.162 10.1.1.162
Load factor 100 0 0 (Hot-Standby) 0
Server port 8005 9005 10005 11005
Non-SSL HTTP/1.1 Connector 8080 9080 10080 11080
AJP 1.3 Connector 8009 9009 10009 11009


James (Sakai mail server)

local.properties

Parameter Tomcat A Tomcat B Tomcat C Tomcat D
smtp.port 8025 9025 10025 11025
smtp.enabled true true true true

Scripts for changing mail delivery server (IPTables)

Switch to local tomcat

#!/bin/bash
#
# IPTABLES change script for JAMES - A
#
 
JAMES_PORT=8025
 
echo "Configuring for Sakai instance A:"
echo 0 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -F PREROUTING
iptables -t nat -F POSTROUTING
iptables -t nat -A PREROUTING -p tcp --dport 25 -i eth0 -j REDIRECT --to-port $JAMES_PORT
iptables -t nat -A PREROUTING -p tcp --dport 25 -i eth1 -j REDIRECT --to-port $JAMES_PORT
iptables -t nat -A PREROUTING -p tcp --dport 25 -i eth2 -j REDIRECT --to-port $JAMES_PORT
iptables -t nat -A PREROUTING -p tcp --dport 25 -i vlan2 -j REDIRECT --to-port $JAMES_PORT
iptables -t nat -A PREROUTING -p tcp --dport 25 -i vlan4 -j REDIRECT --to-port $JAMES_PORT
iptables -t nat -A PREROUTING -p tcp --dport 25 -i vlan5 -j REDIRECT --to-port $JAMES_PORT
/etc/init.d/iptables save
iptables -L PREROUTING -t nat -v

Switch to remote tomcat

#!/bin/bash
#
# IPTABLES change script for JAMES - C
#
 
JAMES_IP=10.1.1.162
JAMES_PORT=10025
SRC_IP=10.1.1.154
 
echo "Configuring for Sakai instance C:"
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -F PREROUTING
iptables -t nat -F POSTROUTING
iptables -t nat -A PREROUTING -p tcp --dport 25 -i eth0 -j DNAT --to $JAMES_IP:$JAMES_PORT
iptables -t nat -A PREROUTING -p tcp --dport 25 -i eth1 -j DNAT --to $JAMES_IP:$JAMES_PORT
iptables -t nat -A PREROUTING -p tcp --dport 25 -i eth2 -j DNAT --to $JAMES_IP:$JAMES_PORT
iptables -t nat -A PREROUTING -p tcp --dport 25 -i vlan2 -j DNAT --to $JAMES_IP:$JAMES_PORT
iptables -t nat -A PREROUTING -p tcp --dport 25 -i vlan4 -j DNAT --to $JAMES_IP:$JAMES_PORT
iptables -t nat -A PREROUTING -p tcp --dport 25 -i vlan5 -j DNAT --to $JAMES_IP:$JAMES_PORT
iptables -t nat -A POSTROUTING -p tcp -d $JAMES_IP --dport $JAMES_PORT -j SNAT --to-source $SRC_IP
/etc/init.d/iptables save
iptables -L PREROUTING -t nat -v
iptables -L POSTROUTING -t nat -v
Personal tools