Join the community today
Become a Member

Nginx Need urgent nginx config help

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by redbird, May 7, 2016.

  1. redbird

    redbird Member

    40
    5
    8
    Aug 28, 2015
    Web
    Ratings:
    +9
    Local Time:
    8:13 PM
    I'm trying to implement memberpress (membership plugin for wordpress) for one of our wp sites on centminmod server.

    From our tests it works fine on apache server but does not want to work on centminmod nginx. We narrowed down the problem to nginx conf rewrite rules.

    From this page: Rewrite Rules developers asking to edit nginx config.

    We tried it - it does not work. Forms do not redirect to a thank you page. Instead of 302 response we are getting 200 and form just refreshes.

    So the problem is in these lines of nginx config:

    Code:
     # Wordpress Permalinks
    try_files $uri $uri/ /index.php?q=$uri&$args;
    
     
      root   /home/nginx/domains/ourdomain.com/public;
        index  index.php;
    
        # Make sure the home page goes home
        if ($uri ~ ^\/$) {
          rewrite ^ /index.php?$args last;
        }
    
        # Main WordPress rewrite rule
        if (!-e $request_filename) {
         rewrite ^ /index.php?$args last;
        }
    
        # Setup lock variables
        set $mplk_uri "/wp-content/plugins/memberpress/lock.php";
        set $mplk_file "/home/nginx/domains/ourdomain.com/public/wp-content/uploads/mepr/rules/${cookie_mplk}";
       
        # don't lock the lock uri
        if ($uri ~* "^/(wp-admin|wp-includes)") { break; }
        if ($uri ~* "\.(php|phtml|jpg|jpeg|gif|css|png|js|ico|svg|woff|ttf|xml)") { break; }
       
        # we don't deal with directories in the url
        if (-d $request_filename) { break; }
       
        # redirect if the lock file's a dir or doesn't exist
        if (-d $mplk_file) { rewrite ^ $mplk_uri last; }
        if (!-e $mplk_file) { rewrite ^ $mplk_uri last; }
    If someone can help us fix this I would be eternally grateful.

    Thank you.
     
  2. redbird

    redbird Member

    40
    5
    8
    Aug 28, 2015
    Web
    Ratings:
    +9
    Local Time:
    8:13 PM
    anyone, please?
     
  3. Epic Internet Marketing

    Epic Internet Marketing Member

    40
    7
    8
    Aug 3, 2014
    New York, NY
    Ratings:
    +18
    Local Time:
    8:13 PM
    1.12.x | PHP 7.1.x
    10.1
    @redbird This sounds oddly developer specific, may need memberpress team to make the config for you.