choose http or https depending on config