Sterilise the jars. Wash in very hot water or on the hot cycle of a dishwasher. Preheat the oven to 160C/325F/Gas 3. Place the jars upside down on a baking tray and dry in the oven for 10-15 minutes.
Heat the red onion and chopped tomatoes in a large heavy-based saucepan over a low heat.
Add the chillies, ginger, star anise, vinegar and sugar. Bring the mixture to the boil, then simmer for about 30 minutes, or until very thick and you can draw a wooden spoon across the base of the pan so that it leaves a channel behind it that does not immediately fill with liquid.
Add the fish sauce and cook for 2-3 more minutes, then spoon into sterilised jars.