PJSIP Outbound Proxy

Back as far as Asterisk 1.8 in chan_sip, there was a concept of an outbound proxy.
The sip.conf file has this:
outboundproxy=proxy.provider.domain ; send outbound signaling to this proxy, not directly to the devices

In creating “endpoints” in 1.8, you could specify a “host=xxx” to send traffic bound for any destination through that host and then onto its final destination.

I have been trying to utilize this same method in PJSIP, but can’t find any way to do it.
The goal is Asterisk -> Sip Proxy -> End Destination
Dialing with the string PJSIP/endpoint/sip:9999@xxx.xxx.xxx.xxx permits me to send packets directly to the end destination, but refuses to utilize the AOR record as the proxy and goes directly to the destination instead of through the proxy.
Using the outbound_proxy in the endpoint, causes the INVITE message’s INVITE header to show “INVITE endpoint” as opposed to the expected “INVITE sip:9999@xxx.xxx.xxx.xxx”.

I have run out of things to try and the code is so convoluted these days, its very difficult to trace how parameters affect the output.

Any help is appreciated.

You want to use SIP loose routing, this is accomplished using something like the following for the outbound_proxy:


The ;lr signifies loose routing, which will not alter the request URI.

I’d also suggest providing the complete configuration if this does not work.

That did fix the issue. (I found this out myself right after I posted this message), but it does not appear to be documented anywhere. I would be good to mention this under the outbound_proxy description in the endpoint section.

It would also be good to mention this under PJSIP dialing examples in the documentation, since it discusses an example where you use an endpoint, but it ignores the AOR references to it, etc.

Thanks for your help!


If there’s a wiki page you came across which would have helped please leave a comment there with some information about how it could have and we’ll incorporate something.