Nginx For WordPress

##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";

gzip_vary on;
gzip_proxied any;
# 大于 4 之后,压缩大小几乎没有变化
gzip_comp_level 4;
gzip_http_version 1.1;
## 小于256B的不要压缩,默认是 20,太小了
gzip_min_length 256;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

server {
        listen      80;
        server_name docker.local;
        root        /var/www/html;
        index       index.php index.html;

        # 加上 * 不会去检查确切的 conf,如果文件不存在,一样可以通过 nginx 测试
        include /var/www/html/nginx.conf*;

        location = /favicon.ico {
                log_not_found off;
                access_log off;
        }

        location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
        }

        location = /xmlrpc.php {
                deny all;
                access_log off;
                log_not_found off;
        }

        location / {

                #禁止指定 user_agent 及 user_agent 为空的访问
                if ($http_user_agent ~ "FeedDemon|JikeSpider|Indy Library|Alexa Toolbar|AskTbFXTV|AhrefsBot|CrawlDaddy|CoolpadWebkit|Java|Feedly|UniversalFeedParser|YandexBot|Microsoft URL Control|Swiftbot|ZmEu|oBot|jaunty|Python-urllib|lightDeckReports Bot|YYSpider|DigExt|YisouSpider|HttpClient|MJ12bot|heritrix|EasouSpider|LinkpadBot|Ezooms|^$" )
                {
                        return 403;
                }

                # This is cool because no php is touched for static content.
                # include the "?$args" part so non-default permalinks doesn't break when using query string
                try_files $uri $uri/ /index.php?$args;
        }

        location ~ \.php$ {
                #include snippets/fastcgi-php.conf;
                #fastcgi_pass docker-php-fpm:9000;
                fastcgi_pass php-fpm:9000;
                include fastcgi_params;
                fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        }

        location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
                expires max;
                log_not_found off;
        }
}