Nginx版本:nginx / 1.10.0(Ubuntu 16.04)
这是我的博客:
server {
listen 80;
server_name blog.khophi.co;
root /var/www/html/blog;
index index.php;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
expires max;
log_not_found off;
}
location ~ /\.ht {
deny all;
}
}
我可以访问网站主页,但文章页面,如myblog.example.com/this-is-my-article
不起作用。
答案 0 :(得分:1)
这可能会有所帮助,
只需查看每一行并删除您认为不需要的内容,
我总是用于每个wordpress设置的配置
server {
listen 80;
server_name www.xxxxyour-domainxxxxx.com xxxxyour-domainxxxxx.com;
return 301 https://xxxxyour-domainxxxxx.com$request_uri;
}
server {
#listen 80;
listen 443 default_server ssl spdy;
server_name xxxxyour-domainxxxxx.com;
ssl on;
ssl_certificate /var/www/xxxxyour-domainxxxxx.com/noyoucant/xxxxyour-domainxxxxx.crt;
ssl_certificate_key /var/www/xxxxyour-domainxxxxx.com/noyoucant/xxxxyour-domainxxxxx.key;
ssl_session_cache shared:SSL:20m;
ssl_session_timeout 10m;
ssl_prefer_server_ciphers on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4;
ssl_stapling on;
ssl_stapling_verify on;
resolver 8.8.8.8 8.8.4.4 valid=300s;
resolver_timeout 10s;
client_max_body_size 64m;
client_body_timeout 60;
#access_log /var/www/xxxxyour-domainxxxxx.com/xxxxyour-domainxxxxx.com.log;
error_log /var/www/xxxxyour-domainxxxxx.com/xxxxyour-domainxxxxx.com-error error;
root /var/www/xxxxyour-domainxxxxx.com;
index index.html index.php;
location / {
gzip_static on;
error_page 418 = @cachemiss;
if ($request_method = POST) { return 418; }
if ($query_string != "") { return 418; }
if ($http_cookie ~* "wordpress_logged_in_") { return 418; }
if ($http_cookie ~* "comment_author_") { return 418; }
if ($http_cookie ~* "wp_postpass_") { return 418; }
try_files "/wp-content/cache/all${uri}index.html" =418;
add_header "X-WPFC-Cache" "HIT";
# choose or modify any of the following cache-control headers
expires 30m;
# add_header "Cache-Control" "max-age=10, must-revalidate";
# add_header "Vary" "Cookie";
}
location @cachemiss {
try_files $uri $uri/ /index.php$is_args$args;
}
### SECURITY ###
error_page 403 =404;
location ~ /\. { access_log off; log_not_found off; deny all; }
location ~ ~$ { access_log off; log_not_found off; deny all; }
location ~* wp-admin/includes { deny all; }
location ~* wp-includes/theme-compat/ { deny all; }
location ~* wp-includes/js/tinymce/langs/.*\.php { deny all; }
location /wp-includes/ { internal; }
#location ~* wp-config.php { deny all; }
location ~* ^/wp-content/uploads/.*.(html|htm|shtml|php)$ {
types { }
default_type text/plain;
}
### DISABLE LOGGING ###
location = /robots.txt { access_log off; log_not_found off; }
location = /favicon.ico { access_log off; log_not_found off; }
### CACHES ###
location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ { access_log off; expires max; }
location ~* \.(woff|svg)$ { access_log off; log_not_found off; expires 30d; }
location ~* \.(js)$ { access_log off; log_not_found off; expires 7d; }
### php block ###
location ~ \.php?$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_hide_header X-Powered-By;
#fastcgi_pass 127.0.0.1:9001;
fastcgi_pass unix:/xxxx/dir/php-fpm/php-fpm.sock;
#fastcgi_pass fpm;
add_header "X-WPFC-Cache" "MISS";
}
}