Pro Sites crashing network with current NGINX.conf

Hi,

I'm trying to configure Pro Sites on an NGINX install and it crashes the network under certain conditions. I'm guessing my current NGINX configs are slightly off.

Plugin installs OK.
Can find blogs by ID but not the search option.
Clicking on the upgrade link goes to rootdomain.com/pro-sites/?Pro=1/
Change Payment Gateway to stripe = whole network goes down: 500 error.

Pro Sites removed and tried to reinstall but get 500 error when network activating.

Does anyone have Pro Sites working with NGINX?

Thanks

  • marvellous

    Hi,

    Thank you for your reply.

    I'm using: Ubuntu 11.10 / WordPress 3.3.1 / Nginx 1.1.5 / Varnish /

    Current active plugins, which work fine.

    Autoptimize
    Custom Admin Bar
    Network Privacy
    NGINX Compatibility (PHP5)
    WordPress MU Domain Mapping

    Pro Sites installed yesterday and "appeared" to be working but realised the link in the admin bar to upgrade was going to a blank page. http://www.rootdomain.com/pro-sites/?Pro=1/. I wasn't sure if that was the correct behavior or not.

    The Pro Sites plugin also created a page called /pro-sites/ in the root-domain and applied the default template to it. When I tried to view it I just got a blank page, again I'm unsure if that is default behavior as I've not properly used the plugin yet.

    To rule out template interference I did the following:

    I created my own Wordpress blank template and assigned it to /Pro-Sites/ and although a blank page it shown it is loading it's own CSS and JS. I tried adding content to the actual Wordpress page, updated the page, and reloaded it. Same as above - no content.

    This test was done with the default PayPal sandbox set.

    Varnish is turned off for the root-domain:

    HTTP/1.1 200 OK =>
    Content-Type => text/html; charset=UTF-8
    Vary => Accept-Encoding
    Date => Thu, 23 Feb 2012 07:28:38 GMT
    X-Varnish => 1632450893
    Age => 0
    Via => 1.1 varnish
    Connection => close
    x-Cache => uncached

    Current NGINX configs:

    1)

    # startup file.
    user www-data;
    worker_processes  4;
    
    error_log  /var/log/nginx/error.log;
    pid        /var/run/nginx.pid;
    
    #daemon     off;
    
    events {
            worker_connections  8000;
    }
    
    http {
    #       rewrite_log on;
    
            include mime.types;
            default_type       application/octet-stream;
            access_log         /var/log/nginx/access.log;
            sendfile           on;
    #       tcp_nopush         on;
            keepalive_timeout  3;
    #       tcp_nodelay        on;
    
             gzip  on;
             gzip_vary on;
             gzip_proxied any;
             gzip_comp_level 2;
             gzip_disable "MSIE [1-6].(?!.*SV1)";
             gzip_types text/plain text/css application/x-javascript text/xml
     application/xml application/xml+rss text/javascript;
    
            client_max_body_size 13m;
            index              index.php index.html index.htm;
    
            # Upstream to abstract backend connection(s) for PHP.
            upstream php {
    #   testing  server unix:/tmp/php-fpm.sock;
                    server 127.0.0.1:9000;
            }
    
            include sites-enabled/*;
    }

    2)

    # Global restrictions configuration file.
    location = /favicon.ico {
            log_not_found off;
            access_log off;
    }
    
    location = /robots.txt {
            allow all;
            log_not_found off;
            access_log off;
    }
    
    # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_St$
    location ~ /\. {
            deny all;
            access_log off;
            log_not_found off;
    }
    
    # Deny access to any files with a .php extension in the uploads directory
    location ~* ^/wp-content/uploads/.*.php$ {
            deny all;
            access_log off;
            log_not_found off;
    }
    
    # Deny access to any files with a .php extension in the uploads directory for m$
    location ~* /files/(.*).php$ {
            deny all;
            access_log off;
            log_not_found off;
    }

    3)

    # Redirect everything to the main site.
    
    server {
        listen       *******;   //Blank for privacy
        server_name  rootdomain.com; //Changed for privacy format the same.
        return       301 http://www.rootdomain.com;
    }
    
    server {
        listen       8080;
        server_name  http://www.rootdomain.com;
        root /site/folder/location/site/;
    
            include global/restrictions.conf;
    
            include global/wordpress-ms-subdir.conf;
    
    }

    4)

    # WordPress multisite subdirectory rules.
    
    # http://wiki.nginx.org/HttpCoreModule
    location / {
            try_files $uri $uri/ /index.php?$args;
    }
    
    # Add trailing slash to */wp-admin requests.
    rewrite /wp-admin$ $scheme://$host$uri/ permanent;
    
    # Directives to send expires headers and turn off 404 error logging.
    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
            expires 1w;
            log_not_found off;
    }
    
    # Pass uploaded files to wp-includes/ms-files.php.
    rewrite /files/$ /index.php last;
    
    set $cachetest "$document_root/wp-content/ms-filemap/${host}${uri}";
    if ($uri ~ /$) {
            set $cachetest "";
    }
    if (-f $cachetest) {
            # Rewrites the URI and stops rewrite processing so it doesn't start over and attempt to pass it to the next rule.
            rewrite ^ /wp-content/ms-filemap/${host}${uri} break;
    }
    
    if ($uri !~ wp-content/plugins) {
            rewrite /files/(.+)$ /wp-includes/ms-files.php?file=$1 last;
    }
    
    # Rewrite multisite '.../wp-.*' and '.../*.php'.
    if (!-e $request_filename) {
            rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) $1 last;
            rewrite ^/[_0-9a-zA-Z-]+.*(/wp-admin/.*\.php)$ $1 last;
            rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 last;
    }
    
    # Pass all .php files onto a php-fpm/php-fcgi server.
    location ~ \.php$ {
            # Zero-day exploit defense.
            # http://forum.nginx.org/read.php?2,88845,page=3
            # Won't work properly (404 error) if the file is not stored on this server, which is entirely possible with php-fpm/php-fcgi.
            try_files $uri =404;
    
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            #NOTE:  "cgi.fix_pathinfo = 0;" in php.ini
    
            include fastcgi_params;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    #       fastcgi_intercept_errors on;
            fastcgi_pass php;
    }

    This is when it all crashed...

    I was looking at the Payment options and stumbled across Stripe. I selected it and the whole network went down - ouched!

    To quickly get the network back I simply used SSH and: sudo rm -R pro-sites

    Which allowed the network to come back to life. I then tried to reinstall Pro-Sites but now after the upload when I click on "Network Activate" it brings down the network again. 500 server error.

    Suspecting a bug in my plugin copy I tried a new one - same result. I can only assume that by brute force removal Pro-Sites has left something behind.

    Any help would be great.

    Thanks.

  • Aaron

    Ok, first for your nginx issue:

    Some rule is incorrectly rewriting all urls to have a slash / after them. Looking through your rules the only I see that is related is:

    # Add trailing slash to */wp-admin requests.
    rewrite /wp-admin$ $scheme://$host$uri/ permanent;

    Not sure if that's the one causing it, so try commenting that out and restart nginx.

    As far as the 500 error, obviously some code in the stripe gateway files is causing a php error for you. You'll have to look at your error log and let me know what that is. It could be you have an older version of PHP, or missing the curl module, or something similar.

  • marvellous

    Hi Aaron,

    Thank you for your reply.

    In relation to the URL: http://www.rootdomain.com/pro-sites/?Pro=1/

    That was a typo. It didn't have the last / on it:

    http://www.rootdomain.com/pro-sites/?Pro=1

    Is that default behavior?

    I'm struggling to find any plugin related errors in the NGINX error log file. I've downloaded a fresh copy of the plugin, replicated the error, and still nothing.

    The only error I can find is from the first install, when it worked. I removed the "Update Notifications Notice" function from pro-sites.php and missed a line, which caused an error.

    I appreciate what your saying about the stripe gateway but I can't even install the plugin without it crashing. At least the first time I installed the plugin, before changing the gateway, it was almost working.

    I'm assuming the plugin defaults to PayPal so it should at least install.

    As for PHP I'm running 5.3.6. I pretty sure curl is installed to but I'll double check.

    Any other ideas?

  • marvellous

    Hi,

    I've played around with the plugin and this is what I'm getting so far..

    When I'm in the dashboard of one of the sites in the network I get the appropriate links to the /pro-site/. page.

    It looks like this:

    http://www.rootdomain.com/pro-site/?bid=3

    However the page shown is blank.

    View source shows the Pro Site includes:

    <link rel='stylesheet' id='psts-checkout-css'  href='http://www.rootdomain.com/wp-content/plugins/pro-sites/pro-sites-files/css/checkout.css?ver=3.1.1' type='text/css' media='all' /> <script type='text/javascript' src='http://www.rootdomain.com/wp-includes/js/jquery/jquery.js?ver=1.7.1'></script> <script type='text/javascript' src='http://www.rootdomain.com/wp-content/plugins/pro-sites/pro-sites-files/js/checkout.js?ver=3.1.1'></script>

    I've selected manual payments from gateway options to isolate the errors where possible.

    I'm currently in the process of creating a new sign-up page, which is located at:

    http://www.rootdomain.com/signup/

    The sign-up page works fine.

    I'm just left with redirecting wp-signup.php to the new page.

    What should I be seeing on the ( /pro-site/?bid=3 ) page and how does this work with either the standard wp-signup.php page or /signup/.

    Thanks

  • Aaron

    I'm struggling to find any plugin related errors in the NGINX error log file. I've downloaded a fresh copy of the plugin, replicated the error, and still nothing.

    Make sure you are looking in the PHP error log, not nginx, they are different. Also that full logging is enabled.

    I appreciate what your saying about the stripe gateway but I can't even install the plugin without it crashing. At least the first time I installed the plugin, before changing the gateway, it was almost working.
    I'm assuming the plugin defaults to PayPal so it should at least install.

    That's because the setting in your db is still to load the stripe gateway. You would need to delete the 'psts_settings' meta key in your sitemeta table. Though if you were able to change the gateway setting back already don't worry about it.

    http://www.rootdomain.com/pro-site/?bid=3

    So this page shows as blank, but in the source there is some html being printed? It would really help to be able to see where the html breaks, can you not share a link?

    Does it show the list of your sites when you take the ?bid=3 off the url?

    What should I be seeing on the ( /pro-site/?bid=3 ) page and how does this work with either the standard wp-signup.php page or /signup/.

    Multisite signup and pro sites checkout are completely unrelated.

  • marvellous

    Hi Aaron,

    Thanks again for taking the time to reply. I've only just read your reply so I've not checked the PHP log file yet. I was only checking the NGINX log file.

    The URL is: http://www.marvellous.ph/pro-site/?bid=3

    I've also added text to the /pro-site/ page from within Wordpress:

    <p>This is a test</p>

    This text is not displaying on /pro-site/ or /pro-site/?bid=3

    I'll update you more as soon as I've looked at the PHP log file.

    Thanks

  • marvellous

    PHP error logging was turned off in PHP.ini so I've:

    1) Set it to on
    2) Specified an error log file
    3) Restarted NGINX
    4) Confirmed the file has write permissions
    5) Uninstalled Pro Sites
    6) Reinstalled Pro Sites
    7) Changed various settings and saved them to try and produce errors.
    8) Added content to the /pro-site/ page and saved it.
    /pro-site/ page not showing content added to page inside Wordpress.
    /pro-site/ showing blank even with <p>This is a test</p>
    9) PHP error log file checked. No errors.

    I'm all out of ideas... anyone else got any?

  • marvellous

    Issue resolved.

    The original issue was related to Pro Sites crashing the network under certain circumstances. That was identified, by Aaron, as being a missing curl module for the selected gateway.

    Before realising that was the problem I simply reinstalled the plugin without the stripe gateway files.

    Then a second issue was identified once the plugin was installed.

    Issue: Blank /pro-site/ page and blank /pro-site/?bid= (plus the blog number on the end)

    This turned out to be a Javascript conflict with my combined file and the included files provided
    by Pro Sites. I had a combined JS file that was obfuscated and it was clashing with the JQuery file.

    I simply removed my JS file and it worked. I then loaded it again without obfuscation and it works fine.

    Therefore I was incorrect in my original assumption that this was an NGINX conf issue.

    Thanks all the same!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.