Make sure that SERVER_NAME is set to HTTP_HOST early enough, if required.