2016-08-27 1 views
0

Lorsque j'appelle ma boutique en ligne dans Chrome ou tout autre navigateur Web sans le préfixe https, j'obtiens un statut 403. Je ne sais pas pourquoi. L'erreur apparaît depuis que j'ai installé et supprimé le plugin hummingbird par wpmudev S'il vous plaît aider. Voici ma conf:État 403 sur l'appel de wordpress sur nginx sans préfixe de protocole

J'utilise wordpress avec woocommerce sur un unbuntu 14.04 aws ec2 instance. De plus, le site est protégé par SSL. Le plugin NGINX Helper est présent et actif mais n'a pas été touché dans cette situation

Merci d'avance.

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; 
    } 
} 

Si possible s'il vous plaît fournir quelques explications, afin que je puisse apprendre quelque chose sur cette question

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

voulez-vous votre site travailler avec 'http' ou simplement rediriger' http' vers 'https'? –

+0

https uniquement. c'est une boutique en ligne. – radscheit

Répondre

0

Vous pouvez essayer de modifier la partie 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; 
    } 
} 
+0

Merci, j'ai essayé et redémarré nginx mais ça n'a pas fonctionné. – radscheit

+0

Vous obtenez toujours '403' quand vous essayez d'ouvrir' http: // www.example.com/', et' https: // www.example.com/'fonctionne bien? –

+0

Oui, cela fonctionne avec le préfixe https mais pas avec http ou aucun préfixe. – radscheit