Laravel 5 Amazon AWS S3 Error: Client error: 403 RequestTimeTooSkewed

Laravel 5 Amazon AWS S3 Error: Client error: 403 RequestTimeTooSkewed

我正在尝试通过 laravel 应用程序

将文件上传到 S3 存储桶

我收到以下错误:

S3Exception in WrappedHttpHandler.php line 152: Error executing "PutObject" on "https://s3-ap-southeast-1.amazonaws.com/

AWS HTTP error: Client error: 403 RequestTimeTooSkewed (client): The difference between the request time and the current time is too large

我做了一些研究,很多人说我的机器时间不同步。我害怕弄乱宅基地,因为我害怕破坏某些东西。我要更改我的应用程序时区吗?真的不确定。

请帮忙,感谢您抽出宝贵时间

您将需要更新宅基地安装的时钟。您可以使用 ntpd 执行此操作以确保这使您的时钟保持最新状态,因为系统在重新启动期间可能会经历一段合理的时间。在 VM 上,这似乎更为重要(但我不确定具体原因)。

要设置 ntpd 并运行在您的宅基地框中执行以下操作;

sudo apt-get install ntp

然后你需要设置你的时间服务器。 运行以下;

sudo nano /etc/ntp.conf

然后确保文件包含以下内容;

server ntp.ubuntu.com
server pool.ntp.org

保存这些更改后 运行;

sudo service ntp restart

完成此操作后,ntpd 将负责保持系统时钟正确,从而最大限度地降低从 S3 返回漂移错误的风险。

最后我要注意不要太担心破坏你的宅基地环境,因为它是一个虚拟机。它的美妙之处在于,如果你出错了,你可以很容易地重建它。

我的网站托管在 AWS Ubuntu 14.04.5 和 Apache

我正在完美上传文件,然后我开始遇到同样的错误。 在“....”上执行 "PutObject" 时出错.... RequestTimeTooSkewed

所以使用@marcus 方法我没有看到那些 server ntp.ubuntu.comserver pool.ntp.org 文件...但是使用命令

timedatectl

我知道我的时区是正确的,但是:

  • 启用 NTP:是
  • NTP 同步:否

NTP 未同步,因此我尝试重新启动 NTP:

sudo service ntp restart

它将我的 NTP 同步 更改为 YES 并解决了问题。