3

I googled a lot about solution to serve with https. Even I tried ngrok, but it doesn't work properly. Below is the code of ngork.

php artisan serve
cd <path-to-ngrok>
./ngrok http localhost:8000

I am sure Laravel has artisan to serve HTTPS.

Conda
  • 141
  • 1
  • 2
  • 12
  • I understand this is one general question, but still finding solution. – Conda Nov 02 '20 at 13:04
  • 2
    The built-in webserver does not support https. You need to use a proper webserver like apache http or nginx to serve under https – apokryfos Nov 02 '20 at 13:13
  • [how to create the virtual host](https://ultimatefosters.com/hosting/setup-a-virtual-host-in-windows-with-xampp-server/), [how to enable https](https://stackoverflow.com/questions/5801425/enabling-ssl-with-xampp), these two link are usd to enable ssl. Is there any method except for that? – Conda Nov 02 '20 at 14:52
  • 1
    Those two links work with xampp (where the 2nd letter stands for apache) not with the built-in webserver. If you set up xampp correctly and follow the directions in those links you should be able to get https working – apokryfos Nov 02 '20 at 15:08

2 Answers2

3

One solution is to use Symfony's 'serve' command instead of artisan serve.

https://symfony.com/download

Install the Symfony CLI locally (I used the homebrew install instructions) and then ran symfony serve in my Laravel root dir. This serves the site under https by default.

Andrew McCombe
  • 1,603
  • 1
  • 12
  • 13
  • I recommend this solution as it's an easy way to install a working certificate and so to test a fully-working https env on any port. – KyleK Jan 15 '23 at 11:18
  • 2
    if you still see that it runs on http by default, then this means you need to run this commant as well `symfony server:ca:install` to install the certificate. – Naser Nikzad Feb 07 '23 at 05:26
1

it's a standard protocol that HTTPS is listening on port 443, you can simply run the command to listen on that port

php artisan serve --port=443

by the way, php artisan serve is for development use only and ssl certificate is for production environment and both of them have no work relation at all as both serve their purpose differently...

although you can customize your web server to install the SSL certificate and and listening on custom port but you are breaking the standard and the public may doubt and not able to accept it...

Abanoub Hany
  • 557
  • 4
  • 7
  • I tried `php atisan serve --port 443`. [http://127.0.0.1:443/login](http://127.0.0.1:443/login) works, but [https://localhost/login](https://localhost/login) **Access forbidden!** _i You don't have permission to access the requested object. It is either read-protected or not readable by the server._ – Conda Nov 02 '20 at 14:21
  • 1
    @conda Maybe this can help [link] https://stackoverflow.com/a/23594870/11567596 – Abanoub Hany Nov 02 '20 at 16:18
  • @NN73 Player // Allow invalid certificates for resources loaded from localhost. chrome://flags/#allow-insecure-localhost –  Юрий Светлов Nov 25 '21 at 20:05
  • No, it doesn't work, none of the above answers work, neither usign 443 port nor enabling chrome insecure localhost. – João Hamerski May 15 '23 at 19:09