What causes the bright flash of light when poking my eye?
Short answer
Pressure phosphenes are believed to be induced by stretch-induced activation of retinal ganglion cells.  

Background
Flashes of light (phosphenes) due to pressure on the eye ball are referred to as pressure phosphenes. Based on an electrophysiological study (Grüsser et al., 1989), eyeball indentation presumably tangentially stretches the retina locally, which variably depolarizes horizontal cells. This in turn depolarizes ON-bipolar ganglion cells, while hyperpolarizing OFF-bipolars. Some ON-center neurons also seem to respond to the removal of the deformation. Bipolar cells connect to the retinal ganglion cells. These ganglion cells carry visual information from the retina via their axons in the optic nerve to the brain. Hence, to answer your question: yes, pressure phosphenes are related to activity in the optic nerve.

Reference
- Grüsser et al., Vis Res (1989); 29(2): 181–94