Design of an Automatic Gain Control Using a JFET
Flip the diode around, swap the positions of the jfet and R2 and then replace the jfet with a mosfet such as a 2N7000.

Input amplitude gets larger, error out goes more positive turning on the mosfet further reducing its resistance and reducing the size of the input signal. 

Connect 5k pot between +5V and -5V with its wiper to non-inverting input of OA2. 

The mosfet's source is then referenced to a constant 0V and the input amplitude is small enough to not make its body diode a problem.

It will never be perfect, there must be some increase in error out in order to increase the mosfet's gate voltage.