Getting protocol from the URL in controller
You can use this in your controller :
$scheme = $this->getRequest()->getScheme();
Otherwise, here is a code allowing you to know all the values returned by the server:
foreach ($_SERVER as $key => $value) { echo $key.' => '.$value.'<br>'; }
Pass request to the controller, get the scheme, or schema and host:
function doSomething(Request $request){ echo $request->getScheme(); echo $request->getSchemeAndHttpHost();}