弹性beanstalk nginx重定向设置不起作用

时间:2017-08-21 10:05:59

标签: amazon-web-services nginx elastic-beanstalk

我试图将http重定向到https,我有这个配置:

files:
    "/etc/nginx/conf.d/robots.conf":
        mode: "000544"
        owner: root
        group: root
        content: |
            server {
                listen 80;

                server_name example.com;

                location =/health {
                    return 200 "health-check";
                }

                location / {
                    if ($http_x_forwarded_proto != "https") {
                        return 301 https://$host$request_uri;
                    }
                }
            }
            server {
                listen 80 default_server;

                server_name www.example.com;

                location =/health {
                    return 200 "health-check";
                }

                location / {
                    if ($http_x_forwarded_proto != "https") {
                        return 301 https://$host$request_uri;
                    }
                }
            }

但是当我转到http://example.comhttp://www.example.com时,没有重定向... 我尝试了多种设置,但似乎它从未完全有效。

1 个答案:

答案 0 :(得分:0)

执行此操作的最佳方法是将配置设置如下

<form name="test4" action="wp-comments-post.php" method="post" id="commentform4" class="comment-form show_info" data-abide enctype="multipart/form-data">
<input type="file" name="pmg_comment_avatar4" id="avatar-upload" />
..........
</form>

<form name="test5" action="wp-comments-post.php" method="post" id="commentform5" class="comment-form show_info" data-abide enctype="multipart/form-data">
<input type="file" name="pmg_comment_avatar5" id="avatar-upload" />
..........
</form>