Make the crust: Crush vanilla wafers and mix with coconut flakes, sugar, salt, and melted butter. Press into a pie pan and bake at 350°F (175°C) for 10 minutes. Cool completely.
Prepare coconut custard: Whisk flour, sugar, salt, coconut milk, milk, and eggs in a saucepan. Cook over medium heat until thick. Stir in butter, vanilla, and rum. Let it cool slightly.
Pour custard into crust: Spread the custard evenly into the cooled crust. Refrigerate for 1 hour to set.
Make pineapple layer: In a small pan, cook crushed pineapple, sugar, lime juice, cornstarch, and rum (optional) until thickened. Cool before spreading over the custard.
Add pineapple topping: Once cooled, gently layer the pineapple mixture over the custard. Chill for at least 3 more hours.
Whip the cream: Beat heavy cream, sugar, vanilla, and optional coconut cream until soft peaks form.
Top and decorate: Spread or pipe whipped cream on top. Garnish with maraschino cherries and toasted coconut if desired.
Serve and enjoy: Slice, serve chilled, and enjoy your tropical escape!