Light is a big factor in the circadian rhythm of melatonin production:
Melatonin secretion increases soon after the onset of darkness, peaks in the middle of the night (between 0200 and 0400 h) and gradually falls during the second half of the night. However, the melatonin rhythm can be acutely interrupted by exposure to light
Thus, exposure to bright light should be reduced in the evenings to ensure melatonin production for nighttime.
Melatonin production is wavelength dependent and suppressed by blue light.  In one study, people were equipped with googles that excluded short wavelength light, while still being exposed to bright light, which resulted in melatonin production similar to what is produced in dim light. 
As for nutrition, melatonin is produced from tryptophan, an essential amino acid. It has been shown that eating tryptophan-rich foods increases melatonin production.
but the influence is minor if compared with the power of the light–dark cycle
Foods rich in tryptophan are those rich in protein, because tryptophan is an amino acid:
chocolate, oats, dried dates, milk, yogurt, cottage cheese, red meat, eggs, fish, poultry, sesame, chickpeas, sunflower seeds, pumpkin seeds, spirulina, bananas, and peanuts
Melatonin is also available as a supplement, and is used for various conditions to do with sleep (circadian rhythm sleep disorders, delayed sleep phase syndrome, etc) However, for normal sleepers, the effect on both sleep on onset and efficiency appears insignificant in meta-analysis of various studies on the subject
Exercise has an effect on melatonin levels. Timing this is important, however; in one study I found (short term, medium number of subjects) exercise in the evenings or at night was more beneficial compared to morning and afternoon, in another (short term study, few subjects) this was found for evening, but not for late evening/night exercise 
A combination of tryptophan-rich foods, exposure to bright light throughout the day and dimmed light (or at least avoidance of blue light in the evening), combined with exercise (possibly in the afternoon), probably works best for boosting natural melatonin production.