我不想在这里提出这个问题,但我已经用尽所有其他资源了。我到处搜索但找不到任何帮助。
我正在将我的WordPress站点从Apache服务器迁移到nginx服务器。我在Apache服务器上使用的插件之一是roksprocket。
http://www.rockettheme.com/wordpress/plugins/roksprocket
当我在全新安装的nginx上安装roksprocket时,插件拒绝工作。当我点击任何保存按钮时,根本不会发生任何事情。
快速浏览Chrome的Dev工具控制台,每次按下保存按钮时都会显示以下javascript错误:
Cannot read property 'status' of undefined
但是当我在一台新的apache服务器上安装带有roksprocket的wordpress时....没问题。
我觉得nginx配置中缺少某些东西会阻止插件获得正确的ajax响应。以下是发送和接收的标题:
`
Remote Address:example.com:80
Request URL:http://example.com/wp-admin/admin-ajax.php?action=roksprocket&nonce=4e79d82c02
Request Method:POST
Status Code:200 OK
Request Headers
Accept:text/javascript, text/html, application/xml, text/xml, */*
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8,es;q=0.6
Connection:keep-alive
Content-Length:158
Content-type:application/x-www-form-urlencoded; charset=UTF-8
Cookie:wordpress_8d5c55f263f1fbeaeacab59de0ed539f=webmaster%7C1399299571%7Cc45cc66c20278417596ac7a86a44f14c; gantry-android-switcher=1; PHPSESSID=lc8g3abuip5geje0mfq9c2m0v2; wp-settings-time-1=1399126752; wordpress_test_cookie=WP+Cookie+check; wordpress_logged_in_8d5c55f263f1fbeaeacab59de0ed539f=webmaster%7C1399299571%7C9762057a27f2113db6f91e2435df4d87; roksprocket-showitems=1; gantry-android-switcher=1; wp-settings-time-3=1399174698
Host:example.com
Origin:http://example.com
Referer:http://example.com/wp-admin/admin.php?page=roksprocket-edit&nonce=4e79d82c02&paged=1&id=0
User-Agent:Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.131 Safari/537.36
X-Requested-With:XMLHttpRequest
Query String Parameters
action:roksprocket
nonce:4e79d82c02
Form Data
id:0
uuid:eb62825b-8b2c-4251-cd0b-ddcfabf45c5c
title:test
params[provider]:wordpress
params[layout]:tabs
task:
model:edit
model_action:save
model_encoding:form
Response Headers
Access-Control-Allow-Credentials:true
Access-Control-Allow-Headers:Content-Type, Authorization, X-Requested-With
Access-Control-Allow-Methods:GET, PUT, POST, DELETE, OPTIONS
Access-Control-Allow-Origin:localhost
Access-Control-Allow-Origin:http://example.com
Cache-Control:no-cache, must-revalidate, max-age=0
Content-Encoding:gzip
Content-Type:text/html; charset=UTF-8
Date:Sun, 04 May 2014 03:38:37 GMT
Expires:Wed, 11 Jan 1984 05:00:00 GMT
Pragma:no-cache
Server:nginx
Transfer-Encoding:chunked
Vary:Accept-Encoding
X-Content-Type-Options:nosniff
X-Frame-Options:SAMEORIGIN
X-Robots-Tag:noindex
NGINX.CONF
user www-data;
worker_processes auto;
pid /var/run/nginx.pid;
events {
worker_connections 4096;
multi_accept on;
}
http {
##
# Easy Engine Settings
##
server_tokens off;
add_header X-Powered-By EasyEngine;
add_header rt-Fastcgi-Cache $upstream_cache_status;
add_header Vary "Accept-Encoding";
# Limit Request
limit_req_status 403;
limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
# Proxy Settings
# set_real_ip_from proxy-server-ip;
# real_ip_header X-Forwarded-For;
fastcgi_read_timeout 300;
client_max_body_size 100m;
# SSL Settings
ssl_session_cache shared:SSL:20m;
ssl_session_timeout 10m;
ssl_prefer_server_ciphers on;
ssl_ciphers HIGH:!aNULL:!MD5:!kEDH;
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 30;
types_hash_max_size 2048;
reset_timedout_connection on;
server_names_hash_bucket_size 128;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
log_format rt_cache '$remote_addr $upstream_response_time $upstream_cache_status [$time_local] '
'$http_host "$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent"';
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##
#include /etc/nginx/naxsi_core.rules;
##
# nginx-passenger config
##
# Uncomment it if you installed nginx-passenger
##
#passenger_root /usr;
#passenger_ruby /usr/bin/ruby;
fastcgi_cache_path /var/run/nginx-cache levels=1:2 keys_zone=WORDPRESS:50m inactive=60m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_cache_use_stale error timeout invalid_header updating http_500 http_503;
fastcgi_cache_valid any 1h;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
fastcgi_param SERVER_NAME $http_host;
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
# Common Upstream Settings
upstream php {
# server unix:/run/php5-fpm.sock;
server 127.0.0.1:9000;
}
upstream debug {
# Debug Pool
server 127.0.0.1:9001;
}
##
# Virtual Host Configs
##
include /etc/nginx/sites-enabled/*;
}
#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}
`
example.com.conf `
server {
# Uncomment The Following Line For Domain Mapping
# listen 80 default_server;
server_name example.com *.example.com;
# Uncomment The Following Line For Domain Mapping
#server_name_in_redirect off;
access_log /var/log/nginx/example.com.access.log rt_cache;
error_log /var/log/nginx/example.com.error.log;
root /var/www/example.com/htdocs;
index index.php index.htm index.html;
set $cache_uri $request_uri;
# POST Requests And Urls With A Query String Should Always Go To PHP
if ($request_method = POST) {
set $cache_uri 'null cache';
}
if ($query_string != "") {
set $cache_uri 'null cache';
}
# Don't Cache Uris Containing The Following Segments
if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|wp-.*.php|index.php|/feed/|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
set $cache_uri 'null cache';
}
# Don't Use The Cache For Logged In Users Or Recent Commenters
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") {
set $cache_uri 'null cache';
}
# Use Cached Or Actual File If They Exists, Otherwise Pass Request To WordPress
location / {
try_files /wp-content/cache/page_enhanced/${host}${cache_uri}_index.html $uri $uri/ /index.php?$args;
}
location ~ ^/wp-content/cache/minify/(.+\.(css|js))$ {
try_files $uri /wp-content/plugins/w3-total-cache/pub/minify.php?file=$1;
}
location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_pass php;
}
# WordPress Common Settings
add_header Access-Control-Allow-Origin "localhost";
add_header Access-Control-Allow-Methods "GET, PUT, POST, DELETE, OPTIONS";
add_header Access-Control-Allow-Headers "Content-Type, Authorization, X-Requested-With";
# Limit Access To Avoid Brute Force Attack
location = /wp-login.php {
limit_req zone=one burst=1 nodelay;
include fastcgi_params;
fastcgi_pass php;
}
# Disable wp-config.txt
location = /wp-config.txt {
deny all;
access_log off;
log_not_found off;
}
# Disallow PHP In Upload Folder
location /wp-content/uploads/ {
location ~ \.php$ {
#Prevent Direct Access Of PHP Files From Web Browsers
deny all;
}
}
# Basic Locations Files
location = /favicon.ico {
access_log off;
log_not_found off;
expires max;
}
location = /robots.txt {
access_log off;
log_not_found off;
}
# Cache Static Files For As Long As Possible
location ~* \.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|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;
}
# Security Settings For Better Privacy
# Deny Hidden Files
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
# Deny Backup Extensions & Log Files
location ~* ^.+\.(bak|log|old|orig|original|php#|php~|php_bak|save|swo|swp)$ {
deny all;
access_log off;
log_not_found off;
}
# Return 403 Forbidden For readme.(txt|html) or license.(txt|html)
if ($request_uri ~* "^.+(readme|license)\.(txt|html)$") {
return 403;
}
# Status Pages
location /nginx_status {
stub_status on;
access_log off;
satisfy any;
auth_basic "Restricted Area";
auth_basic_user_file htpasswd-ee;
# Allowed IP Address List
allow 127.0.0.1;
deny all;
}
location ~ ^/(status|ping) {
include fastcgi_params;
fastcgi_pass php;
satisfy any;
auth_basic "Restricted Area";
auth_basic_user_file htpasswd-ee;
# Allowed IP Address List
allow 127.0.0.1;
deny all;
}
# EasyEngine Admin Tools
# PMA Settings
location /pma {
return 301 https://$host:22222/db/pma;
}
location /phpMyAdmin {
return 301 https://$host:22222/db/pma;
}
location /phpmyadmin {
return 301 https://$host:22222/db/pma;
}
# Adminer Settings
location /adminer {
return 301 https://$host:22222/db/adminer;
}
}
`