Make the soup base: Put the onion, ginger, garlic, chile, lemongrass, coriander, cumin, turmeric, fish sauce, and brown sugar in a food processor. Purée to make a paste, scraping down the sides as needed. Heat the oil in a heavy soup pot or Dutch oven over medium heat until hot but not smoking. Add the paste mixture and sauté, stirring often, until it softens, becomes very aromatic, and deepens in color, about 8 minutes. Stir in the shrimp shells and cook until they turn pink, about 2 minutes. Add the chicken broth, water, coconut milk, lime juice, and salt and bring to a boil. Lower the heat so that the broth simmers gently for 30 minutes. Strain the broth through a fine sieve and discard the solids. Clean the pot; return the broth to the pot, season with salt to taste, and return to a simmer.
While the soup base is simmering: Bring a large pot of water to a boil and then remove from the heat. Put the rice noodles in the water and let sit until tender, 5 to 10 minutes. Drain, rinse, and distribute among four large, shallow soup bowls.
Slice the cucumber into 1/4-inch rounds, stack the rounds, and slice into thin matchsticks. Put the cucumber sticks in a medium bowl and toss with the bean sprouts, sliced chiles (if using), and herbs.
Just before serving, add the shrimp to the broth and gently simmer until they’re just cooked through, about 3 minutes. Ladle the hot soup over the noodles. Arrange a mound of the cucumber and bean sprout mixture in the center of the bowl, top with a lime wedge, and serve immediately.