尝试为某些用户在 Magento 电子商务平台上传图片后,CloudFront 出现 http 403 错误

http 403 error from CloudFront after attempting to upload image in Magento e-commerce platform for some users

我们在 AWS Cloudfront 后面的购物网站使用 Magento 电子商务平台。在所见即所得的创建页面中,有一个上传图片的选项。一些用户报告在他们选择图像并按下上传按钮后发生 403 错误,而对于其他用户来说上传图像有效。

当其中一些用户出现 403 时,我在 nginx 访问或错误日志中没有看到任何错误消息。但是,我确实在 CloudFront 日志中看到以下错误:

date        time        x-edge-location sc-bytes    c-ip            cs-method   cs(Host)                        cs-uri-stem                                                                                                 sc-status   cs(Referer)                                                                                                 cs(User-Agent)                                                                      cs-uri-query            cs(Cookie)  x-edge-result-type  x-edge-request-id           x-host-header           cs-protocol cs-bytes    time-taken  x-forwarded-for     ssl-protocol    ssl-cipher                  x-edge-response-result-type cs-protocol-version fle-status  fle-encrypted-fields    c-port      time-to-first-byte  x-edge-detailed-result-type sc-content-type             sc-content-len sc-range-start   sc-range-end
2020-01-20  10:22:13    MAN50-C1        570         xx.xx.xx.xx     POST        jhgfjgfjsd.cloudfront.net       /index.php/ctrl-web-team/cms_wysiwyg_images/upload/type/image/key/88fdfad6d6b726871662108fad3d3de3/         403         https://www.example.com/index.php/ctrl-web-team/cms_page/new/key/c7e419205e2c23c854cd4ea1d741bdad/          Mozilla/5.0%20(X11;%20Linux%20x86_64;%20rv:72.0)%20Gecko/20100101%20Firefox/72.0    SID=gm892fbgp7lep0      -           Error               Z6p-RiAuq7RA7ryi3iNHD==     www.example.com         https       16778       0.844       -                   TLSv1.2         ECDHE-RSA-AES128-GCM-SHA256 Error                       HTTP/2.0            -           -                       42776       0.844               Error                       text/html                   134             -               -
2020-01-20  10:22:17    MAN50-C1        1547        xx.xx.xx.xx     POST        jhgfjgfjsd.cloudfront.net       /index.php/ctrl-web-team/cms_wysiwyg_images/contents/type/image/key/0f36c05043efc3435jj342d6a3071e6a47/     200         https://www.example.com/index.php/ctrl-web-team/cms_page/new/key/c7e419205e2c23c854cd4ea1d741bdad/          Mozilla/5.0%20(X11;%20Linux%20x86_64;%20rv:72.0)%20Gecko/20100101%20Firefox/72.0    isAjax=true             -           Miss                nu8CAYvBxQnpvMbAhdgdf=      www.example.com         https       545         0.612       -                   TLSv1.2         ECDHE-RSA-AES128-GCM-SHA256 Miss                        HTTP/2.0            -           -                       42776       0.612               Miss                        text/html;%20charset=UTF-8  -               -               -

感谢任何指导。

由于某些请求被 AWS WAF(Web 应用程序防火墙)阻止而发生错误。查看与 WAF 中的 ACL 关联的规则。

我必须在 AWS WAF Classic 中定义一个额外的 "String and regex matching" 规则来允许请求。