nginx、Magento&;云锋

nginx、Magento&;云锋,magento,nginx,amazon-cloudfront,Magento,Nginx,Amazon Cloudfront,我继承了一个运行Magento&nginx的网站。我对nginx几乎一无所知,对Magento也相当了解。该站点配置为使用Amazon Cloudfront CDN,但是所有图像、js和css都返回301重定向到源站点。我有一个运行Apache的开发站点,其Magento、MySQL和Cloudfront设置与此设置相同,运行正常,因此我非常确定nginx的配置文件存在问题。文件中写入了一些重写内容,我的假设是,当在skin.mydomain.com上请求资产时,它会重定向到www.mydoma

我继承了一个运行Magento&nginx的网站。我对nginx几乎一无所知,对Magento也相当了解。该站点配置为使用Amazon Cloudfront CDN,但是所有图像、js和css都返回301重定向到源站点。我有一个运行Apache的开发站点,其Magento、MySQL和Cloudfront设置与此设置相同,运行正常,因此我非常确定nginx的配置文件存在问题。文件中写入了一些重写内容,我的假设是,当在skin.mydomain.com上请求资产时,它会重定向到www.mydomain.com,而不是从CDN提供文件。我为js.mydomain.com、skin.mydomain.com和cloud.mydomain.com设置了CNAME记录,这些记录都指向同一个Cloudfront CDN。以下是nginx配置文件中似乎适用的部分:

server {
   listen 80;
   ##127.0.0.1:8080
   server_name mydomain.com;
   rewrite / $scheme://www.$host$request_uri permanent; ## Forcibly prepend a www
}

server {
    listen 80;
    ##127.0.0.1:8080 default
        ## SSL directives might go here
        listen 443 default ssl;
        ssl_certificate     /etc/nginx/
        ssl_certificate_key /etc/nginx/

    server_name www.mydomain.com;
    ## *.mydomain.com; Domain is here twice so server_name_in_redirect will favour the www
    root /var/www/magento;

    location / {
        index index.html index.php; ## Allow a static html file to be shown first
        try_files $uri $uri/ @handler; ## If missing pass the URI to Magento's front handler
        expires 30d;
        if ($request_uri ~* "\.(ico|css|js|gif|jpe?g|png)$") {
            access_log off;
            expires max;
        }
        port_in_redirect off;
    }
任何帮助都将不胜感激,因为我已经为此工作了几乎一整天,并希望在某个时候停止工作


谢谢

第一个
服务器
指令似乎正在强制重写www

server {
 . . .
    rewrite / $scheme://www.$host$request_uri permanent; ## Forcibly prepend a www
 . . . 
}