Thursday, September 10, 2009

Configuring OPENSER as proxy

OpenSer is easily configurable and modular, the necessary configuration is done in openser.cfg. This take care of the incoming SIP messages and routing them to server address configured.The proxy also makes a few checks (and modifications) on the message and sends an error message if necessary.


Edit the Makefile, and at line 287 change this instruction:

Install: all mk-install-dirs install-cfg install-bin install-modules \
install-doc install-man

To

Install: openser mk-install-dirs install-cfg install-bin install-modules \
install-doc install-man

Now, making sure that you have super-user privileges, execute:

> make install
Setting up the OpenSER proxy
Edit openser.cfg

# ----------- global configuration parameters ------------------------

#Uncomment these lines to enter debugging mode
debug=9 # debug level
Fork=no
Log_stderror=yes


check_via=no # (cmd. line: -v)
dns=no # (cmd. line: -r)
rev_dns=no # (cmd. line: -R)
listen= ip this pc will listen on
port=5060
children=4
fifo="/tmp/openser_fifo"
load modules and set parameters

# ------------------ module loading ----------------------------------

# Uncomment this if you want to use SQL database
loadmodule "/usr/local/lib/openser/modules/mysql.so"

loadmodule "/usr/local/lib/openser/modules/sl.so"
loadmodule "/usr/local/lib/openser/modules/tm.so"
loadmodule "/usr/local/lib/openser/modules/rr.so"
loadmodule "/usr/local/lib/openser/modules/maxfwd.so"
loadmodule "/usr/local/lib/openser/modules/usrloc.so"

loadmodule "/usr/local/lib/openser/modules/registrar.so"

# ----------------- setting module-specific parameters ---------------

# -- usrloc params --

# Uncomment this if you want to use SQL database
# for persistent storage and comment the previous line
modparam("usrloc", "db_mode", 0)

# -- rr params --
# add value to ;lr param to make some broken UAs happy

modparam("rr", "enable_full_lr", 1)
Changes in main routing logic
replace
if (method=="REGISTER") {..}
with
if (method=="ACK") {
route(1);
exit;
} if (method=="INVITE") {
route(3);
exit;
} else if (method=="REGISTER") {
route(2);
exit;
};


Add the route[2] and route[3] function for proxy behaviour in openser.cfg


route[2] {
#rewrinting the host allows the registrar to know that the message is destined for it
rewritehost("192.168.1.103"); # openser server ip address
if(!t_relay_to_udp("192.168.1.103","5060")) {
sl_reply_error();
};
exit;
}

route[3] {
# -----------------------------------------------------------------
# INVITE Message Handler
lookup("aliases");
if (uri!=myself) {
route(1);
exit;
};
if (!lookup("location")) {
sl_send_reply("404", "User Not Found");
exit;
};


Now use this configuration script in 'usr/local/etc/openser/'

No comments:

Post a Comment