How far back from the glass really depends on the lens, with the 105 Macro lens I can within 8" of the subject.
I've tried extension tubes, but for some reson I just don't like them.
I NEVER use a flash, just doesn't work when shooting thru glass for obvious reason, or atleast doesn't work with my experience level which is still in the "learning curve"
I stage most of shots, which means that I have a dedicated stagging area in my tank that has a clean, black background with no surrounding corals to compete with the image, this is why most of my shots have really clean looking backgrounds and it's also why most of my images appear like they are at eye level.
Lighting is tricky, sometimes I have to move a coral back and forth under the tank lights so that I get good color and correct brightness, then I have to wait for the coral to open, take a shot, inspect the image, reposition the coral, wait, repeat, etc...Thats why sometimes it may take me an entire day to capture the image I want.
I usually try and position the corals directly under my lights and slightly behind the lights. All of these images were shot under 250w 15k phoenix bulbs
The key to great quality, detailed images is
1) turn off all the pumps in the tank, tentacles moving around cause image blur
2) clean the glass on the INSIDE of the tank right before tanking the shot
3) USE A TRIPOD - it's critical for detailed macro work
4) use a shutter remote, if you don't have one then use the camera timer. Pushing the shutter release button will cause minor camera motion which causes image blur.
5) Don't use autofocus, shoot in manual, make sure your eye exams are up todate, I can tell every single time when I need to have my eyes rechecked as I can't capture the details I want, sure enought I make a trip to eye doc and he makes a minor adjustment to my contact lens rx
6) shoot in "A" mode and play around with fStop settings for depth of field
The 18-55 lens that comes with the standard D40 kit is not the best, but will work fine for most people, you just have to be very critical that you follow the above 6 steps and you should be able to capture good images.
Let me dig up some that I took with my 18-55 when I first got the camera
Hope this helps.