as moddedmicra said, i'd suggest using an offset spanner on the nut and a small adjustable spanner holding the middle shock shaft After (importantly) using a spring compressor to safely unload the nut and make removal easier (or else the nut would be hard to remove whilst loaded and then you'd get half a spring in ur face)
if you don't have a compressor, you could alternatively refit the strut back onto the chassis and hub and put a jack under the lower hub balljoint to compress the spring then undo the nut above before gently lowering the jack to seperate the upper spring cap from the strut assembly.