Magento2符合CloudFront的默认配置是什么?

时间:2019-06-25 12:54:55

标签: amazon-web-services nginx magento2 amazon-cloudfront nginx-config

被CloudFront严重卡住

我目前正在使用Akamai CDN,并且想迁移到CloudFront(因为我的所有基础架构都托管在AWS上)。

我已经在CF上设置了发行版,但是每当我尝试单独访问静态内容时,仅缓存图像,而不缓存静态文件。它以HIT进行响应,但是除了媒体内容(woff,woff2除外)之外,网站没有其他HIT(浏览时)。

下面是我的CF和Nginx Config,请帮助找出我做错了什么地方...

AWS-云前端配置...

CF-General

CF-Origin

CF-DefaultBehavior

CF-StaticBehavior

CF-MediaBehavior

Nginx配置...

map $http_host $MAGE_RUN_CODE {
        int-www.example.net admin;
        int-en.example.net en;
        int-ar.example.net ar;
        int-en-ae.example.net en_ae;
        int-ar-ae.example.net ar_ae;
        int-en-sa.example.net en_sa;
        int-ar-sa.example.net ar_sa;
        int-en-om.example.net en_om;
        int-ar-om.example.net ar_om;
        int-en-bh.example.net en_bh;
        int-ar-bh.example.net ar_bh;
        int-en-kw.example.net en_kw;
        int-ar-kw.example.net ar_kw;
}

log_format int-example-net    '$remote_addr - $remote_user [$time_local] "$request" '
                              '$status $body_bytes_sent "$http_referer" '
                              '"$http_user_agent" $request_time $upstream_response_time';

server {
        listen  80;
        server_name int-en.example.net int-ar.example.net origin.example.net statics.example.net int-www.example.net int-ar-sa.example.net int-en-sa.example.net int-en-ae.example.net int-ar-ae.example.net int-en-om.example.net int-ar-om.example.net int-en-bh.example.net int-ar-bh.example.net int-en-kw.example.net int-ar-kw.example.net;

        access_log      /var/log/nginx/int-www.example.net_access.log;
        error_log       /var/log/nginx/int-www.example.net_error.log;

        return 301 https://$server_name$request_uri;
}

server {
        listen  443;
        server_name int-en.example.net int-ar.example.net origin.example.net statics.example.net int-www.example.net int-en-sa.example.net int-ar-sa.example.net int-en-ae.example.net int-ar-ae.example.net int-en-om.example.net int-ar-om.example.net int-en-bh.example.net int-ar-bh.example.net int-en-kw.example.net int-ar-kw.example.net;

        access_log      /var/log/nginx/int-www.example.net_access.log;
        error_log       /var/log/nginx/int-www.example.net_error.log;

        set $MAGE_ROOT /var/www/magento2-fastest;
        set $MAGE_MODE default;
        include /var/www/magento2-fastest/nginx.conf;

        ssl on;
        ssl_certificate /etc/ssl/certs/example-net.crt;
        ssl_certificate_key /etc/ssl/private/example-net.key;
        ssl_session_cache shared:SSL:20m;
        ssl_session_timeout 180m;
        ssl_prefer_server_ciphers on;
        ssl_ciphers ECDH+AESGCM:ECDH+AES256:ECDH+AES128:DH+3DES:!ADH:!AECDH:!MD5;
        add_header Strict-Transport-Security "max-age=31536000" always;
        add_header Access-Control-Allow-Origin "*";

        rewrite ^/ord/(.*)$ /order/index/tracking?OrderId=$1 redirect;
        rewrite /taradod$ https://int-ar-sa.example.net/media/taradod/index.html$1 permanent;

        location ~ no_cache {
                return 403;
        }

        location /status {
                stub_status on;
                allow 127.0.0.0/8;
                deny all;
        }

        location /en/ {
                rewrite ^/en/(.*)$   https://int-en.example.net/$1 last;
        }

        location /ar/ {
                rewrite ^/ar/(.*)$   https://int-ar.example.net/$1 last;
        }

        location /logs {
               autoindex on;
        }

        location ~* .(woff|eot|ttf|svg|mp4|webm|jpg|jpeg|png|gif|ico|css|js)$ {
                expires 365d;
        }

        location ~* .(json)$ {
                add_header Access-Control-Allow-Origin *;
        }
}

0 个答案:

没有答案