Laravel https请求错误提示:Invalid request (Unsupported SSL request)

在LNMP环境中生成私有证书并配置nginx,我现在可以访问https://localhost
图片描述

在laravel 路由中添加一条

Route::get('/ssl', array('https' => true, function() {
        return View('welcome');
    })
);

再启动laravel

php artisan serve

当我访问https://localhost:8000时并不成功
提示错误

[Sat Jan 21 22:33:29 2017] 127.0.0.1:43310 Invalid request (Unsupported SSL request)
[Sat Jan 21 22:33:30 2017] 127.0.0.1:43312 Invalid request (Unsupported SSL request)
[Sat Jan 21 22:33:32 2017] 127.0.0.1:43314 Invalid request (Unsupported SSL request)
[Sat Jan 21 22:33:33 2017] 127.0.0.1:43316 Invalid request (Unsupported SSL request)
[Sat Jan 21 22:33:35 2017] 127.0.0.1:43318 Invalid request (Unsupported SSL request)
[Sat Jan 21 22:33:36 2017] 127.0.0.1:43320 Invalid request (Unsupported SSL request)

我应该怎么做才能让https能够访问?
任何提示或者帮助都非常感谢!

阅读 12.4k
1 个回答

首先说一下为什么会报错,这是用因为php内置的web服务器仅仅用于本地测试使用,不支持ssl加密,所以使用php artisan serve来启动https服务显然是不行的。

可以使用php-fpm的方式来启动你的web服务,这样就可以支持https的访问方式了。或者是使用stunnel对http的服务进行一下包装,参考openSSL not working with PHP built-in webserver

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题