The solution in the question is correct.
The constraint $i\ne j$ is the one that gives us trouble. To get around it we have to split into two cases: (i) $i<j$, and (ii) $i>j$ (but still $i<2j$)
thus
$S\to S_{(i)} \mid S_{(ii)}$
as the first production splits into this two cases.
Now, divide and conquer: case (i) is very simple, since we only need $i<j$,
$S_{(i)} \to aS_{(i)}b \mid B$
$ B \to Bb \mid b$
This is your $S_2$.
For case (ii), we need to $j< i < 2j$, so for every single $a$, the variable $C$ will generate exactly one $b$, and at a certain point we switch to the variable $D$ that will generate two $a$'s for each $b$.
$S_{(ii)} \to aCb $
$ C \to aCb \mid D$
$ D \to aaDb \mid aab$
This is your $S_1$.