php 此分发未配置为允许 HTTP 请求

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31253694/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 22:19:53  来源:igfitidea点击:

This distribution is not configured to allow the HTTP request

phphtmlformsamazon-web-serviceshttps

提问by Info at Layoverbox

This distribution is not configured to allow the HTTP request method that was used for this request. The distribution supports only cachable requests. 

I have configure the website to only accept https on amazon cloudfront. In a nutshell, you have a php login form, and upon successful login it redirects the user as follow:

我已将网站配置为仅接受 amazon cloudfront 上的 https。简而言之,您有一个 php 登录表单,成功登录后,它会按如下方式重定向用户:

 if(isset($_POST['login'])){

[...]
        echo "<script>window.open('coursePayment.php?crs_id=$crs_id','_self')</script>";

below is the form:

下面是表格:

 <form style="margin-top:-20px" method='post' action='' class='form-horizontal' role='form'>
       <input type="hidden" id="couponCodeLogin" name="couponCodeLogin">
        <input type="hidden" id="couponCodeLoginAmount" name="couponCodeLoginAmount">
<br><br>
 <div class="group">      
            <input type='text' class='form-control' name='email' required>
      <span class="highlight"></span>
      <span class="bar"></span>
      <label>Email</label>
    </div>

    <div class="group">      
            <input type='password' class='form-control' name='pass' required>
      <span class="highlight"></span>
      <span class="bar"></span>
      <label>Password</label>
    </div>


            <h5 style="color:#FF6400; cursor:context-menu; margin-top:0px" class="displayForgotPassword">Forgot your password? Click here to retrieve it.</h5><br>
            <input type='submit' id='moreInfoButton' name='login' value='Continue' class='btn btn-danger'>                               
          </form> 

采纳答案by Mircea

What the error is trying to tell you is that you cannot use POST. Going to guess that cacheable means GET in this context. You need to go ahead and configure cloud front to allow "upload requests" like POST, PUT, etc. IN this case the request will go to the origin that Cloudfront uses.

错误试图告诉您的是您不能使用 POST。猜测在这种情况下,可缓存意味着 GET。您需要继续并配置 cloud front 以允许“上传请求”,如 POST、PUT 等。在这种情况下,请求将转到 Cloudfront 使用的源。

Aws docs: http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-creating.html

Aws 文档:http: //docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-creating.html

http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-creating-console.html

http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-creating-console.html

http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-values-specify.html

http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-values-specify.html

Look for Allowed HTTP Methods in last link.

在最后一个链接中查找允许的 HTTP 方法。

回答by cgenco

This error happens because CloudFront isn't configured to accept an HTTP request it's being sent (like POSTor PATCH).

发生此错误是因为 CloudFront 未配置为接受正在发送的 HTTP 请求(如POSTPATCH)。

To fix it, change your CloudFront distributions settings to accept all HTTP methods.

要修复它,请更改您的 CloudFront 分配设置以接受所有 HTTP 方法。

To do that, click on the Behaviorstab of your CloudFront distribution, select the default behavior, click Edit, change the Allowed HTTP Methodsto GET, HEAD, OPTIONS, PUT, POST, PATCH, DELETE, then click Yes, Editin the bottom right to save your changes.

为此,请单击BehaviorsCloudFront 分配的选项卡,选择默认行为,单击Edit,将 更改Allowed HTTP MethodsGET, HEAD, OPTIONS, PUT, POST, PATCH, DELETE,然后单击Yes, Edit右下角的 以保存更改。

Change Allowed HTTP Methods in a CloudFront distribution

更改 CloudFront 分配中允许的 HTTP 方法

It may take several minutes for your CloudFront distribution to propagate the changes.

您的 CloudFront 分配可能需要几分钟时间来传播更改。