The provincial government in a statement said the attack was carried out in the vicinity of Najmuddin Akhundzada roundabout located in Behsud district.
The statement further added that two civilians were killed in the attack along with two soldiers inside the security post.
Another soldier also sustained injuries in the attack, the provincial government added.
According to the local officials, the assailant militants also suffered casualties after the Afghan forces responded to their fire but the exact number has not been ascertained so far.
Nangarhar is among the relatively calm provinces in eastern Afghanistan but the anti-government armed militant groups have recently increased their insurgency activities in some parts of the province during the recent years.
Taliban insurgents and militants affiliated with the Islamic State of Iraq and Syria (ISIS) terrorist group are actively operating in a number of the remote districts of Nangarhar.
This comes as the Afghan forces are busy conducting counter-insurgency operations in some of the restive districts of Nangarhar as part of the Shaheen-25 operations launched over a month ago.