Rename constants SERVER_X to correct ENVIRONMENT_X

In this case, “environment” is a more appropriate term than “server”.
Also adding http(s) protocol check.