You simply need to do what the OEM has been doing for several decades, knock sensors and a computer to control the ignition timing. If you have a carb, at least a way to control the timing electronically, they build stand alone systems just to control the timing.
Do all the stuff listed by others quench, etc. but bottom line is you have to control the timing curve.