How to Make a https site with Laravel5. And, How to resolve 80 ports problem at Cloud9

In developing larvel application At cloud9,
Port 80 problem is often coming out.

■Cloud9 adds port 80 to Laravel route

Well I do not know, but I tried to do in various ways,
It happens in following two conditions.

  • Current page address is “http://…”
  • You pressed the link that is written in the relative path ()<a href=”/…”)

Basically address is “https://…” at cloud9,
but laravel generate the full path link (<a href=”http://…”) by default,
we are “http://..” address unwittingly, and error is occured

So, It’s OK to keep address “https://…”.
The following is a solution.

■Laravel 5 – redirect to HTTPS

There are two files to modify.

# /app/Http/Middleware/ForceHttps.php

    public function handle($request, Closure $next)
//        if (!app()->environment('local')) {
            // for Proxies
            if (!$request->isSecure()) {
                return redirect()->secure($request->getRequestUri());
//        }
        return $next($request);

Function to determine in the environment has been commented out ,so for the time being unnecessary,

Basically, It checks $request is whether sequre(https://…) or not,
If not https, to change to https. That’s all.

However,specification on, When it flew request at https,


To those described above, It return false.
And it will be permanent loop in this state.
(For more information on here, currently unknown. I guess proxy issues…)

Therefore, to add a sentence below.


It’s mean to tell the system “Client IP is a reliable proxy”.

# /app/Http/Kernel.php

Add the following sentence to $middleware.


Now, http → https is applied to all routes,Port80 problem should not occur.
Try it.

Thank you.