My experience (and my friend who's a sleep doc agrees) is that melatonin is worthless for anyone doing shift work. If you work nights for an extended period of time and you need to adjust your sleeping times for the next month or three OR if you're just having trouble sleeping at night then it works. But melatonin is to regulate your sleep ie you must be sleeping/attempting to sleep at the same time every night. Does not work when you alternate backside/frontside every couple of days.
I flew cargo long haul for years and now passenger international, I find it's best to have a routine. But, as stated before, everyone is different.
No coffee within 4-6 hrs of bed
Dark & cold room
Earplugs
Shower to relax and brush teeth immediately
Absolutely no TV/iPad/anything electronic once in room
Agree with above poster, limit carbs and sugar as much as you can all day. Protein is the best. And actually I sleep best on an almost empty stomach... Last meal roughly 4 hrs before bed.
There are definitely good sleep aids out there... Just have to be careful (as OP said) when taking it within a certain time of flying. I am pretty sure ambien is allowed by the FAA if taken more than 24 hrs before a flight .... But don't quote me on that time.