WordPress.org

Ready to get started?Download WordPress

Forums

WordPress MU Domain Mapping
[resolved] Nginx + WordPress MU mapping domain + Nginx Helper + Memcached/WP-FFPC (7 posts)

  1. L D
    Member
    Posted 7 months ago #

    Hi,

    I'm experiencing an issue after memcached/WP-FFPC configuration.

    Before I used supercache, and it worked fine!

    Now:

    I've installed, tested and memcached works fine, but the mapped domains seems not redirect well.

    Mapped domain:
    domainA.staging.example.com > staging.domainA.com
    domainB.staging.example.com > staging.domainB.com

    If staging.domainA.com or B are default
    webserver redirect all url (A e B, primary and not) to other CMS on same machine. Logs shows 302 redirect, ERROR!

    If domainA.staging.example.com or B are default
    webserver redirect right! But secondary domain redirect to other CMS, why?

    I think is an Nginx configuration issue:

    My config:

    auth_basic              "Restricted";
    auth_basic_user_file    conf.d/.htpasswd;
    
    map $http_host $blogid {
            default 1;
    
            include /var/www/staging.server/staging.example.com/http/wordpress/wp-content/uploads/nginx-helper/map.conf;
    }
    
    server {
            ## Listen ports
            listen 80;
    #       listen [::]:80;
    
            # use _ if you want to accept everything, or replace _ with domain
            server_name _;
            root /var/www/staging.server/staging.example.com/http/wordpress/;
            ## This should be in your http block and if it is, it's not needed here.
            index index.php;
    
            # set up logging
            access_log /var/log/nginx/access.log;
            error_log /var/log/nginx/error.log;
    
            ## PHP5-FPM
            location ~ (\.php) {
            # these settings are usually in fastcgi_params
                    location ~* wp\-login\.php {
                            include fastcgi_params;
                            fastcgi_pass php-fpm;
                    }
    
                    fastcgi_index                           index.php;
                    fastcgi_connect_timeout                 10;
                    fastcgi_send_timeout                    180;
                    fastcgi_read_timeout                    180;
                    fastcgi_buffer_size                     512k;
                    fastcgi_buffers                         4       256k;
                    fastcgi_busy_buffers_size               512k;
                    fastcgi_temp_file_write_size            512k;
                    fastcgi_intercept_errors                on;
                    fastcgi_split_path_info ^(.+\.php)(/.*)$;
                    fastcgi_keep_conn                       on;
    
                    fastcgi_param   QUERY_STRING                    $query_string;
                    fastcgi_param   REQUEST_METHOD                  $request_method;
                    fastcgi_param   CONTENT_TYPE                    $content_type;
                    fastcgi_param   CONTENT_LENGTH                  $content_length;
                    fastcgi_param   SCRIPT_FILENAME                 $document_root$fastcgi_script_name;
                    fastcgi_param   SCRIPT_NAME                             $fastcgi_script_name;
                    fastcgi_param   REQUEST_URI                             $request_uri;
                    fastcgi_param   DOCUMENT_URI                    $document_uri;
                    fastcgi_param   DOCUMENT_ROOT                   $document_root;
                    fastcgi_param   SERVER_PROTOCOL                 $server_protocol;
                    fastcgi_param   GATEWAY_INTERFACE               CGI/1.1;
                    fastcgi_param   SERVER_SOFTWARE                 nginx;
                    fastcgi_param   REMOTE_ADDR                             $remote_addr;
                    fastcgi_param   REMOTE_PORT                             $remote_port;
                    fastcgi_param   SERVER_ADDR                             $server_addr;
                    fastcgi_param   SERVER_PORT                             $server_port;
                    fastcgi_param   SERVER_NAME                             $server_name;
    
                    fastcgi_param   PATH_INFO                               $fastcgi_path_info;
                    fastcgi_param   PATH_TRANSLATED                 $document_root$fastcgi_path_info;
                    fastcgi_param   REDIRECT_STATUS                 200;
    
                    # uncomment these for HTTPS usage
                    #fastcgi_param  HTTPS                                   $https if_not_empty;
                    #fastcgi_param  SSL_PROTOCOL                    $ssl_protocol if_not_empty;
                    #fastcgi_param  SSL_CIPHER                              $ssl_cipher if_not_empty;
                    #fastcgi_param  SSL_SESSION_ID                  $ssl_session_id if_not_empty;
                    #fastcgi_param  SSL_CLIENT_VERIFY               $ssl_client_verify if_not_empty;
    
                    fastcgi_pass php-fpm;
            }
    
            location / {
                    try_files $uri $uri/ @memcached;
            }
    
            # try to get result from memcached
            location @memcached {
                            default_type text/html;
                            set $memcached_key data-$scheme://$host$request_uri;
                            set $memcached_request 1;
    
                            # exceptions
                            # avoid cache serve of POST requests
                            if ($request_method = POST ) {
                                            set $memcached_request 0;
                            }
    
                            # avoid cache serve of wp-admin-like pages, starting with "wp-"
                            if ( $uri ~ "/wp-" ) {
                                            set $memcached_request 0;
                            }
                            # avoid cache serve of wp-admin-like pages, starting with "wp-"
                            if ( $uri ~ "/wp-" ) {
                                            set $memcached_request 0;
                            }
    
                            if ($http_cookie ~* "comment_author_|wordpressuser_|wp-postpass_|wordpress_logged_in_" ) {
                                    set $memcached_request 0;
                            }
    
                            if ( $memcached_request = 1) {
                                    add_header X-Cache-Engine "WP-FFPC with memcached via nginx";
                                    memcached_pass memcached-servers;
                                    error_page 404 = @rewrites;
                            }
    
                            if ( $memcached_request = 0) {
                                    rewrite ^ /index.php last;
                            }
                    }
    
            ## rewrite rules
                    location @rewrites {
                            add_header X-Cache-Engine "";
                            rewrite ^ /index.php last;
                    }
    #### Inizio SP
    
            client_body_buffer_size  1K;
            client_header_buffer_size 1k;
            client_max_body_size 1m;
            large_client_header_buffers 2 1k;
    
    #### Fine SP
    
            location = /favicon.ico {
                    log_not_found off;
                    access_log off;
            }
    
            location = /robots.txt {
                    deny all;
                    log_not_found off;
                    access_log off;
            }
    
            location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
                    expires max;
                    log_not_found off;
            }
    
            location ~ /\. {
                    deny  all;
                    access_log off;
                    log_not_found off;
            }
    
            location ^~ /blogs.dir {
                    internal;
                    alias /var/www/staging.server/staging.example.com/http/wordpress/wp-content/blogs.dir ;
                    access_log off;
                    log_not_found off;
                    expires max;
            }
    
    #WPMU Files
            location ~ ^/files/(.*)$ {
                    try_files /wp-content/blogs.dir/$blogid/$uri /wp-includes/ms-files.php?file=$1 ;
                    access_log off;
                    log_not_found off;
                    expires max;
            }
    
    }

    Regards
    D

    http://wordpress.org/plugins/wordpress-mu-domain-mapping/

  2. Ron Rennick
    MultiSite Guru
    Plugin Author

    Posted 7 months ago #

    webserver redirect all url (A e B, primary and not) to other CMS on same machine. Logs shows 302 redirect, ERROR!

    Do you have permanent redirect checked in the DM settings?

  3. L D
    Member
    Posted 7 months ago #

    I have WP and Magento installed.

    WP conf like:

    server_name staging.example.com *.staging.example.com;

    Mage conf like:

    server_name mage.staging.example.com *.mage.staging.example.com;

    This is my DM:

    Domain Options:
    [ ] Remote Login
    [X] Permanent redirect (better for your blogger's pagerank)
    [X] User domain mapping page
    [X] Redirect administration pages to site's original domain (remote login disabled if this redirect is disabled)
    [ ] Disable primary domain check. Sites will not redirect to one domain name. May cause duplicate content issues.

    Disabling memcached (service memcached stop) issue go on!

    Thank you for your support
    Regards
    D

  4. L D
    Member
    Posted 7 months ago #

    I supposed WP-FFPC needs a fix because adding this:

    server_name staging.example.com *.staging.example.com staging.domainA.com staging.domainB.com;

    works fine!

    I think WP-FFPC, with line:

    set $memcached_key data-$scheme://$host$request_uri;

    elides map section:

    map $http_host $blogid {
    
            default 1;
    
            include /var/www/staging.server/staging.armoniaph.it/http/wordpress/wp-content/uploads/nginx-helper/map.conf;
    
    }

    What do you thinking about?

    Thank you
    D

  5. L D
    Member
    Posted 7 months ago #

    Take a look here

    Regards
    D

  6. L D
    Member
    Posted 7 months ago #

    The issue regards WP-FFPC plugin

Reply

You must log in to post.

About this Plugin

About this Topic