The jihadists opened fire on a convoy of traders under military escort outside a village near the northeastern town of Banki on Thursday, killing two military escorts and injuring seven traders, according to the sources.
"The (Boko Haram) terrorists ambushed the convoy around 6:00 pm (1700GMT) as it approached Banki and killed two of the soldiers providing cover for the convoy," a military officer said.
"The attackers fired indiscriminately and seven civilians were injured," the officer said.
The jihadist fighters seized a truck belonging to a humanitarian organisation during the ambush, but the driver managed to escape, according to a militiaman fighting the jihadists in Banki, who have a similar toll.
A militiamen said the seized truck belonged to Intersos, an NGO representing the World Food Programme (WFP) in Banki.
Banki, which is 130 kilometres (80 miles) southeast of the Borno state capital Maiduguri, houses 45,000 people displaced by the Boko Haram conflict who live in a sprawling camp which opened in 2015 following raids on villages in the area.
Traders from Banki travel to Maiduguri twice a week under military escort to bring in supplies.
Boko Haram continue to launch sporadic attacks in the town and ambush troops on the highway.
Last October two Nigerian soldiers were killed when troops on foot patrol stepped on a mine around Kumshe village near Banki.
Boko Haram's bloody insurgency began in northeastern Nigeria in 2009 but has since spread into neighbouring countries, prompting a regional military response.
In Nigeria alone, more than 27,000 people have been killed over the past decade, and some 1.8 million people have been forced out of their homes by the violence.