Not sure if it will work but you could constrain the "red" joint to a locator and lock the translate x and z of the locator making it only available for movement in y