当我在Chrome或其他没有https前缀的网络浏览器中调用我的网上商店时,我获得了403状态。我不知道为什么。自从我通过wpmudev安装并删除了hummingbird插件后出现错误。
这是我的conf:
我在Ubuntu 14.04 aws ec2实例上使用WordPress和woocommerce。此外,该网站受到ssl保护。 NGINX Helper插件存在并处于活动状态,但在这种情况下没有被触及。
fastcgi_cache_path /var/run/nginx-cache levels=1:2 keys_zone=WORDPRESS:100m inactive=60m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_cache_use_stale error timeout invalid_header http_500;
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
server {
listen *:80;
server_name example.com www.example.com 52.29.193.xxx;
#root /home/wordpress/htdocs;
root /var/www/letsencrypt;
location ^~ /.well-known/acme-challenge/ {
default_type "text/plain";
root /var/www/letsencrypt;
}
index index.html index.htm index.php index.cgi index.pl index.xhtml;
#rewrite ^(.*) https://example.com$1 permanent;
}
server {
listen *:443 ssl;
ssl_certificate_key /etc/letsencrypt/live/www.example.com/privkey.pem;
ssl_certificate /etc/letsencrypt/live/www.example.com/fullchain.pem;
server_name example.com www.example.com 52.29.193.xxx;
root /home/wordpress/htdocs;
index index.html index.htm index.php index.cgi index.pl index.xhtml;
#rewrite ^(.*) https://example.com$1;
port_in_redirect off;
set $skip_cache 0;
error_log off;
access_log off;
# POST requests and urls with a query string should always go to PHP
if ($request_method = POST) {
set $skip_cache 1;
}
if ($query_string != "") {
set $skip_cache 1;
}
# Don't cache uris containing the following segments
if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml") {
set $skip_cache 1;
}
if ($request_uri ~* "/home.*|/store.*|/cart.*|/my-account.*|/checkout.*|/addons.*") {
set $skip_cache 1;
}
if ($request_uri ~* "/en/home.*|/en/store.*|/en/cart.*|/en/my-account.*|/en/checkout.*|/en/addons.*") {
set $skip_cache 1;
}
if ( $arg_add-to-cart != "" ) {
set $skip_cache 1;
}
if ( $cookie_woocommerce_items_in_cart != "0" ) {
set $skip_cache 1;
}
# Don't use the cache for logged in users or recent commenters
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
set $skip_cache 1;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
# Directives to send expires headers and turn off 404 error logging.
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;
}
# Pass all .php files onto a php-fpm/php-fcgi server.
location ~ \.php$ {
set $rt_session "";
if ($http_cookie ~* "wc_session_cookie_[^=]*=([^%]+)%7C") {
set $rt_session wc_session_cookie_$1;
}
if ($skip_cache = 0 ) {
more_clear_headers "Set-Cookie*";
set $rt_session "";
}
fastcgi_cache_key "$scheme$request_method$host$request_uri$rt_session";
try_files $uri =404;
include fastcgi_params;
fastcgi_pass unix:/var/lib/php5-fpm/wordpress.sock;
fastcgi_index index.php;
fastcgi_read_timeout 300;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_cache_bypass $skip_cache;
fastcgi_no_cache $skip_cache;
fastcgi_cache WORDPRESS;
fastcgi_cache_valid 60m;
}
location ~ /purge(/.*) {
fastcgi_cache_purge WORDPRESS "$scheme$request_method$host$1";
}
location /user {
rewrite ^ https://$host$request_uri? permanent;
}
location = /xmlrpc.php {
deny all;
access_log off;
log_not_found off;
}
location ~ ^/wp-content/uploads/wsoe/(.*?)\.csv$ {
rewrite / permanent;
}
}
如果可能请提供一些解释,以便我可以了解这个问题
fastcgi_cache_path /var/run/nginx-cache levels=1:2 keys_zone=WORDPRESS:100m inactive=60m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_cache_use_stale error timeout invalid_header http_500;
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
server {
listen 127.0.0.1:8080;
listen *:443 ssl;
ssl_certificate_key /etc/letsencrypt/live/www.example.com/privkey.pem;
ssl_certificate /etc/letsencrypt/live/www.example.com/fullchain.pem;
server_name example.com www.example.com;
root /home/wordpress/htdocs;
index index.html index.htm index.php index.cgi index.pl index.xhtml;
port_in_redirect off;
set $skip_cache 0;
error_log off;
access_log off;
# POST requests and urls with a query string should always go to PHP
if ($request_method = POST) {
set $skip_cache 1;
}
if ($query_string != "") {
set $skip_cache 1;
}
# Don't cache uris containing the following segments
if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml") {
set $skip_cache 1;
}
if ($request_uri ~* "/home.*|/store.*|/cart.*|/my-account.*|/checkout.*|/addons.*") {
set $skip_cache 1;
}
if ($request_uri ~* "/en/home.*|/en/store.*|/en/cart.*|/en/my-account.*|/en/checkout.*|/en/addons.*") {
set $skip_cache 1;
}
if ( $arg_add-to-cart != "" ) {
set $skip_cache 1;
}
if ( $cookie_woocommerce_items_in_cart != "0" ) {
set $skip_cache 1;
}
# Don't use the cache for logged in users or recent commenters
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
set $skip_cache 1;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
# Directives to send expires headers and turn off 404 error logging.
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;
}
# Pass all .php files onto a php-fpm/php-fcgi server.
location ~ \.php$ {
set $rt_session "";
if ($http_cookie ~* "wc_session_cookie_[^=]*=([^%]+)%7C") {
set $rt_session wc_session_cookie_$1;
}
if ($skip_cache = 0 ) {
more_clear_headers "Set-Cookie*";
set $rt_session "";
}
fastcgi_cache_key "$scheme$request_method$host$request_uri$rt_session";
try_files $uri =404;
include fastcgi_params;
fastcgi_pass unix:/var/lib/php5-fpm/wordpress.sock;
fastcgi_index index.php;
fastcgi_read_timeout 300;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_cache_bypass $skip_cache;
fastcgi_no_cache $skip_cache;
fastcgi_cache WORDPRESS;
fastcgi_cache_valid 60m;
}
location ~ /purge(/.*) {
fastcgi_cache_purge WORDPRESS "$scheme$request_method$host$1";
}
#location = /xmlrpc.php {
# deny all;
# access_log off;
# log_not_found off;
#}
}
答案 0 :(得分:0)
您可以尝试将http部分修改为:
server {
listen *:80;
server_name example.com www.example.com 52.29.193.xxx;
location ^~ /.well-known/acme-challenge/ {
default_type "text/plain";
root /var/www/letsencrypt;
}
location / {
rewrite ^(.*) https://example.com$1 permanent;
}
}