Why not just do this at web server level?
You can redirect to HTTPS or HTTP, here's an example: https://bashy.im/blog/nginx-redirect-to-https-with-without-www-subdomain
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I've been enjoying my Laravel development recently and I've finally managed to create my first full web app. I've been testing it on a production server, using Forge and Digital ocean, and things are working great.
I now want to switch to HTTPS from HTTP, and I created a Middleware called SecureRequests that forces all non http requests to become https request like so:
SecureRequest.php
public function handle($request, Closure $next)
{
if (!$request->secure() && !\App::isLocal()) {
return redirect()->secure($request->getRequestUri());
}
return $next($request);
}
I've also applied it to all requests, via the kernel, and again - it works well. However, when I push to production, I can't access my site anymore (I believe due to not having a SSL certificate).
Is there an easy way to do this via forge?
Connection refused means there's no service listening on that port. You can check on the server with
netstat -lpn | grep "443"
Please or to participate in this conversation.