这是一个很好的nginx配置吗?

时间:2015-06-29 06:19:16

标签: php redirect nginx webserver http-status-code-301

这是一个很好的nginx配置吗?我是否正确地使用了301重定向(我有多个域名并希望所有域名都指向https://domain.ru),并且我没有搞砸了他未来的所有搜索引擎优化?它将成为使用nginx,percona和php-fpm的1-2个wordpress网站的服务器

    server {
    listen 80;
    listen [::]:80;
    return 301 https://domain.ru$request_uri;
    server_name domain.com www.domain.com домен-домен.рф www.домен-домен.рф домен.рф www.домен.рф www.domain.ru domain.ru;
}

server {
        listen 443 ssl;
        listen [::]:443 ssl;
        ssl on;
        ssl_certificate /etc/ssl/12345.crt;
        ssl_certificate_key /etc/ssl/12345.key;
    server_name www.domain.ru;
    return 301 https://domain.ru$request_uri;
}

server {
        listen 443 ssl;
        listen [::]:443 ssl;
        ssl on;
        ssl_certificate /etc/ssl/12345.crt;
        ssl_certificate_key /etc/ssl/12345.key;

        root /var/www/html;

        index index.html index.php index.htm index.nginx-debian.html;

        server_name domain.ru;

        gzip on;
        gzip_disable "msie6";
        gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;

        location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
                access_log off;
                log_not_found off;
                expires max;
    }

        location / {
                try_files $uri $uri/ =404;
        }

        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
        }
}

0 个答案:

没有答案