我想将 Laravel 网站部署到亚马逊,所以我执行了以下步骤:
请注意,Tg443 具有有效的 SSL 证书
将 Ec2 的安全组更改为负载均衡器的安全组
**结果: **
该网站在 http 端口 80 上完美运行,健康检查也是如此,我可以从任何浏览器正常访问该网站
该网站在 https:443 上返回 [502 Bad Gateway]
在(ssh 到实例后)/var/log/httpd/error_log 中,出现以下错误/var/www/html/.htaccess: RewriteCond: bad flag delimiters
所以,我尝试了,根据链接enforce-https-laravel:
要.htaccess按照链接中所述在 laravel 应用程序中进行配置,请刷新所有内容 `php artisan config:cache,重试运行状况检查,但结果相同
我删除.htaccess并配置了app/Providers/AppServiceProvider.php:
use Illuminate\Contracts\Routing\UrlGenerator;
public function boot(UrlGenerator $url)
{
if(env('ENFORCE_SSL', false)) {
$url->forceScheme('https');
}
}
Run Code Online (Sandbox Code Playgroud)
ENFORCE_SSL=true …Github: 存储库
这张图片显示了我所做的详细信息,您可以跳过并阅读下面的管理员重置密码部分

配置/auth.php:
<?php
return [
/*
|--------------------------------------------------------------------------
| Authentication Defaults
|--------------------------------------------------------------------------
|
| This option controls the default authentication "guard" and password
| reset options for your application. You may change these defaults
| as required, but they're a perfect start for most applications.
|
*/
'defaults' => [
'guard' => 'web',
'passwords' => 'users',
],
/*
|--------------------------------------------------------------------------
| Authentication Guards
|--------------------------------------------------------------------------
|
| Next, you may define every authentication guard …Run Code Online (Sandbox Code Playgroud)