• Hello,

    I tried to improve my nginx confiugration. I can’t login via /wp-admin weather wp-login.php. Actually I got no clue, I got a white screen by this url:

    wp-login.php?redirect_to=https%3A%2F%2Fdomain-name.de%2Fwp-admin%2F&reauth=1

    This is my nginx configuration at the moment:

    
    limit_req_zone $http_x_forwarded_for zone=DIYB:20m rate=100r/s; # you missed line like this
    
    fastcgi_cache_path /var/run/wordpress levels=1:2       
                       keys_zone=DIY:100m inactive=60m;
    fastcgi_cache_key "$scheme$request_method$host$request_uri";
    
    server {
      listen       *:443 ssl;
    
      server_name        domainname.de www.domainname.de;
      root               /var/www/domainname.de/wordpress;
    
      ssl on;
    
      index  index.php;
    
      access_log            /var/log/nginx/domainname.de_ssl_access.log combined;
      error_log             /var/log/nginx/domainname.de_ssl_error.log;
    
      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)$ {
        expires max;
        log_not_found off;
        access_log off;
      }
    
      
      # fast cgi cache
       set $skip_cache 0;
    
        # 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 ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass
            |wordpress_no_cache|wordpress_logged_in") {
            set $skip_cache 1;
        }
     
        set $cache_uri $request_uri;
    
        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-(app|cron|login|register|mail).php
                              |wp-.*.php|/feed/|index.php|wp-comments-popup.php
                              |wp-links-opml.php|wp-locations.php |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';
        }
    
        location = /favicon.ico {
            log_not_found off; 
            access_log off;
        }
    
        location = /robots.txt {
            log_not_found off;
            access_log off;
        }
    
        location ~ /\. {
          deny  all; 
          access_log off;
          log_not_found off;
        }
    
    location ~* ^/wp-content/uploads/.*.(html|htm|shtml|php|js|swf)$ {
        deny all;
    }
    
    location ~* wp-config.php {
        deny all;
    }
    
    location = /wp-login.php {
      limit_req zone=DIYB burst=1 nodelay;
      fastcgi_pass  unix:/var/run/php-fpm/domainname.de.sock;
    }
    
      location / {
        try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html 
                $uri $uri/ /index.php?$args;
        rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml$ "/index.php?xml_sitemap=params=$2" last;
        rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml\.gz$ "/index.php?xml_sitemap=params=$2;zip=true" last;
        rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html$ "/index.php?xml_sitemap=params=$2;html=true" last;
        rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html.gz$ "/index.php?xml_sitemap=params=$2;html=true;zip=true" last;
      }
      location ~ \.php$ {
        try_files $uri =404;
        root      /var/www/domainname.de/wordpress;
        include   /etc/nginx/fastcgi.conf;
    
        fastcgi_pass  unix:/var/run/php-fpm/domainname.de.sock;
        fastcgi_connect_timeout 3m;
        fastcgi_read_timeout 3m;
        fastcgi_send_timeout 3m;
        fastcgi_cache_bypass $skip_cache;
        fastcgi_no_cache $skip_cache;
        fastcgi_cache DIY;
        fastcgi_cache_valid  60m;
      }
    
      include /etc/nginx/snippets/letsencrypt.conf;
    }
    
    
Viewing 1 replies (of 1 total)
  • Thread Starter peacefulwarri0r

    (@peacefulwarri0r)

    I figured out the related lines:

    #location = /wp-login.php {
    #  limit_req zone=DIYB burst=1 nodelay;
    #  fastcgi_pass  unix:/var/run/php-fpm/diy-ist-cool.de.sock;
    #}
    

    I can login again now.

Viewing 1 replies (of 1 total)
  • The topic ‘nginx caching issue’ is closed to new replies.