Don't know what your fidelity requirements are, but if you're looking for a good quality dedicated chip for it, THAT semiconductor makes a few - you basically just need the rectifier and cap and a resistor divider to make sure the gain input is set correctly. Otherwise, they can be found looking for a compressor or compader circuit, there are a few ICs available.
I know it's possible to make them with a JFET to attenuate the input signal, but it has to be biased correctly to stay in the linear region, so there's a limited signal that it can variably attenuate.