Laravel 7 with Laradock 正在生产中:电子邮件验证 403 无效签名 [英] Laravel 7 with Laradock on production: email verification 403 invalid signature

查看:76
本文介绍了Laravel 7 with Laradock 正在生产中:电子邮件验证 403 无效签名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有很多帖子和 StackOverflow 的答案,但没有一个能帮助我解决这个问题.

There are many posts out there and StackOverflow answers, but none has helped me solve this problem.

我在生产服务器上将 Laradock 用于 Laravel 应用程序.Nginx 和 PHP 7.4 上的 Laravel 版本为 7.24.0.

I am using Laradock for a Laravel app on a production server. The Laravel version is 7.24.0 on Nginx and PHP 7.4.

但是,如果我通过 mailtrap 测试电子邮件验证,则会收到此错误

However, if I test the email verification via mailtrap, I get this error

403 |签名无效.

我已经执行了 php artisan key:generate 并且我可以在我的 .env 文件中看到它:

I already have executed php artisan key:generate and I can see it in my .env file:

APP_NAME="The cool app"
APP_ENV=production
APP_KEY=base64:S1ABrOXZ1ldmYqfjBvZfupwBNM+m10MWINqEvj/eGbg=
APP_DEBUG=true
APP_URL=https://my-domain.com

原本Nginx的默认配置是:

Originally, the Nginx default configuration is:

server {

    listen 80;
    listen [::]:80;

    # For https
    # listen 443 ssl default_server;
    # listen [::]:443 ssl default_server ipv6only=on;
    # ssl_certificate /etc/nginx/ssl/default.crt;
    # ssl_certificate_key /etc/nginx/ssl/default.key;

    server_name my-domain.com;
    root /var/www/public;
    index index.php index.html index.htm;

    location / {
         try_files $uri $uri/ /index.php$is_args$args;
    }

    location ~ \.php$ {
        try_files $uri /index.php =404;
        fastcgi_pass php-upstream;
        fastcgi_index index.php;
        fastcgi_buffers 16 16k;
        fastcgi_buffer_size 32k;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        #fixes timeouts
        fastcgi_read_timeout 600;
        include fastcgi_params;
    }

    location ~ /\.ht {
        deny all;
    }

    #location /.well-known/acme-challenge/ {
    #    root /var/www/letsencrypt/;
    #    log_not_found off;
    #}
}

我也试过了:

try_files $uri $uri/ /index.php?$query_string; 

按照此处的建议.

但除了在我的本地环境中之外,没有任何效果.

But nothing works, except in my local environment.

网址示例是.

https://my-domain.com/email/verify/3/28d707536a36800a7cfaaaa5f5e29eca3ac2b38a?expires=1597101566&signature=2685421462a1756e38bee693801f11e2f2ed6645e3d0ad361413a758b9ca6fab

我检查了验证"电子邮件按钮和网络浏览器 URL,它们看起来相同.

I checked both the "verify" email button and the web browser URLs and they look the same.

另外,我刚刚试过

$ php artisan config:cache

但没有运气:/我仍然得到那个 403 |无效签名错误

But no luck :/ I still get that 403 | Invalid signature error

有人可以对此有所了解吗?否则,如何调试?

Can anyone shed some light on this? Otherwise, how to debug this?

解决了!欢呼我已经应用了这个 GitHub 问题由 yawmanford 回答 中所说的内容:

Solved! Hurra I have applied what is said in this GitHub issue answered by yawmanford:

内部AppServiceProvider.php

Inside AppServiceProvider.php

public function boot()
{
    if($this->app->environment('production'))
    {
        \URL::forceScheme('https');
    }
}

然后在 TrustProxies.php

Then in TrustProxies.php

protected $proxies = '*';

最后,在我运行的 workspace 容器内:

Finally, inside the workspace container I ran:

工匠配置:缓存

这就成功了!

你怎么看?

推荐答案

我怀疑这是你的 nginx 配置的原因.你可以试试这个吗?

I suspect that the reason for this is your nginx configuration. Can you try this instead?

    try_files $uri $uri/ /index.php?$query_string;

我还看到您在应用程序中使用了 https,但您的 nginx 配置没有 SSL 配置.您可以尝试在应用中使用 http 看看它的表现吗?

I also see that you are using https in the app but your nginx configs don't have SSL configs. Can you try and use http in the app see how it performs?

这篇关于Laravel 7 with Laradock 正在生产中:电子邮件验证 403 无效签名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆