Laravel 8中的自定义路线仅收听HTTP请求
我的应用程序在HTTPS协议上使用端口443的稳定性运行,但是我正在使用AWS EBS,其中始终在HTTP上使用端口80执行健康检查。我创建了用于在所有路线上强制执行HTTPS的中间件,但是当我启用它时,健康检查AWS失败,但该网站正常工作。
HTTPSFORCE中间件处理功能:
public function handle($request, Closure $next)
{
if (!$request->secure() && app()->environment('production')) {
return redirect()->secure($request->getRequestUri());
}
return $next($request);
}
如何创建一个自定义路由,该路由始终使用HTTP协议倾听到端口80,以便AWS的健康检查将在HTTP路由上执行,而我的整个网站在HTTPS工作?
My application works with stability on HTTPS protocol with port 443 but I'm using AWS EBS where health checks are always performed on HTTP with port 80. I've created middleware for enforcing HTTPS on all routes but when I enabled it, the health check fails on AWS but the website works properly.
HTTPsForce middleware handle function:
public function handle($request, Closure $next)
{
if (!$request->secure() && app()->environment('production')) {
return redirect()->secure($request->getRequestUri());
}
return $next($request);
}
How can I create a custom route which listens to port 80 with HTTP protocol always so the health check by AWS would perform on HTTP route while my whole website working in HTTPS?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在特定路由上排除中间件:
https://lararavel.com/docs/ 9.x/中间件#排除中间软件
You can exclude middleware on specific routes:
https://laravel.com/docs/9.x/middleware#excluding-middleware