0

I wanna test my Laravel Sail Docker project with HTTPS enabled. How can I achieve this?

I thought share made this possible, but that is not correct.

▶ sail share --subdomain=foobar
Thank you for using expose.
Local-URL:      host.docker.internal:82
Dashboard-URL:      http://127.0.0.1:4040
Expose-URL:     http://foobar.laravel-sail.site:8080

I need to run my application on https://, but only get it working with http.

user1469734
  • 851
  • 14
  • 50
  • 81
  • Maybe this can help you https://stackoverflow.com/questions/65302372/how-do-you-enable-ssl-using-laravel-8-sail – Kenny Horna May 12 '21 at 14:37

1 Answers1

0

You can only use HTTP, they (Laravel) don't configure HTTPS. You can read it here

PS: I switched to ngrok and add this to App\Providers\AppServiceProvider.php and it worked perfect:

public function boot()
{
    // Fix https
    if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1) || isset($_SERVER['HTTP_X_FORWARDED_PROTO']) &&  $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') {
        $this->app['request']->server->set('HTTPS', true);
    }
}

I used the solution from Ayman Elmalah.

Toan Ka
  • 77
  • 1
  • 4
  • In Laravel Homestead it is possible to use HTTPS, because Homestead comes with a .crt file, which you can import in your browsers (I successfully have imported it in Firefox, Chrome, Safari). Probably, in Laravel Sail that should be possible as well – Pathros Jan 22 '23 at 02:10