backport of #5496, fixes #5421 for stable5

@DeepDiver1975 @karlitschek @jancborchardt please review. already contains latest SERVERROOR / WEBROOT fixes from master