what role did the Nile play in Egyptian military history before modern times?

well, there is the well known case of Ahmose the son of Ebana who served in a marines unit back in the early New Kingdom period and managed to get military decorations at the rate of around one award per one enemy killed.

So I was wondering, how easy or hard was it to use the Nile in premodern military conflict? Can the river be blocked off with a big chain to prevent enemy troops transports from moving past your fortresses? Is it wide enough to have a meaningful naval battle? Up in the Delta, was there a threat of low key piracy from Phoenicians or in more recent times the Byzantines and the Barbary pirates? (I don’t mean the ancient Sea Peoples invasions, just run-of-the-mill stuff in more recent times).

If the Byzantines achieved significant naval technical superiority for awhile from late 7th century onwards with the Greek fire, why couldn’t they use their navy to either reconquer northern Egypt or at least terrorize its government into paying tribute?

The Nile was incredibly important for transportation, both for civilian and military traffic. The Ancient Egyptian Navy was used for this purpose. Millennia later transport by ships was still quicker than marching overland.

Egypt’s coast was threatened at numerous periods in its history. The Sea People (some speculate they could be comprised of Phoenicians, but there are many other theories), a group of raiders attacked the Nile Delta during the 19th/20th Dynasties. The Nile is certainly big enough to have a battle - the invasion of the Sea Peoples culminated with the Battle of the Delta, where Ramesses III repulsed them. No chains, but he did line the shores with archers to fire at any ships that came close.

The Hyksos also threatened the Nile, actually managing to occupy the Delta and establish a capital there at Avaris.

The Byzantines after the loss of Egypt were embroiled in the Byzantine-Arab Wars, which didn’t go well for them. From the wiki:

As for the Barbary States; at the time Egypt was part of the Ottoman Empire, which itself has inextricable links with the Barbary coast;

Essentially they’d be biting the (very powerful) hand that feeds them, and attacking fellow Muslims no less. A few pirates no doubt operated in the area, but there were easier targets.

It made a passable, if hardly impenetrable defensive barrier - an Egyptian army could at times maneuver along its length and a river crossing in the face of a hostile force was always an operation fraught with peril. During the opening phase of the Wars of the Diadochi, the failure of Perdiccas to force a crossing of the Nile at Pelusium in the face of Ptolemy’s troops sealed his fate.

The annual floods in particular could impede or strand an invader, which is what happened to the army of Saint Louis IX during the Seventh Crusade. These could be supplemented by blocking navigable channels ( in whatever manner ) and diverting the river to flood specific areas, making them far more difficult to traverse, a tactic used for example by the pharaoh Nectanebo I of the resurgent XXXth dynasty to block a Persian army at Pelusium ( again - it was the Eastern bastion of the Nile and thus the entryway from the east into the system ), using the now defunct Pelusiac branch of the Nile.

In general, as THE defining geographic feature of Egypt’s terrain, you have to figure it influenced the thinking and operations of anyone who ever campaigned there, one way or another.