Nginx+Nginx plugin+domain mapping plugin=image 404 no preview


#1

Hoping that someone can shed a little light on my problem. I have Nginx and WordPress multisite working well enough. When I map a domain to one of my sites everything seems fine until I attach media. The preview for the image isnt there. If i got and edit the image I can see and edit it. If I follow the image's link it returns a Wordpress provided 404 page. I am a noob and have been over my nginx settings and read everything I could but still cant see why this is happening. Kinda hoping someone can point out my mistakes. and shed some light upon the dark place Ive been all day.

map $uri $blogname{  
~^(?P/[^/]+/)files/(.*) $blogpath ;  

}

map $blogname $blogid{ default -999;

#Ref: http://wordpress.org/extend/plugins/nginx-helper/  
#include /var/www/wordpress/wp-content/plugins/nginx-helper/map.conf ;  

}

You may add here your

server {

root /var/www;  
index index.php index.html index.htm;  
server_name example.com www.example.com;  

location ~ ^(/[^/]+/)?files/(.+) {  
    try_files /wp-content/blogs.dir/$blogid/files/$2 /wp-includes/ms-files.php?file=$2 ;  
    access_log off; log_not_found off; expires max;  
}  

#avoid php readfile()  
location ^~ /blogs.dir {  
    internal;  
    alias /var/www/wp-content/blogs.dir ;  
    access_log off; log_not_found off; expires max;  
}  

if (!-e $request_filename) {  
    rewrite /wp-admin$ $scheme://$host$uri/ permanent;    
    rewrite ^(/[^/]+)?(/wp-.*) $2 last;   
    rewrite ^(/[^/]+)?(/.*\.php) $2 last;   
}  

location / {  
    try_files $uri $uri/ /index.php?$args ;  
}  


#add some rules for static content expiry-headers here  
 location ~ .*\.(php|php5)?$ {  
            fastcgi_split_path_info ^(.+\.php)(/.+)$;  
            # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini  
            # With php5-cgi alone:  
            fastcgi_pass 127.0.0.1:9000;  
            # With php5-fpm:  
    #       fastcgi_pass unix:/var/run/php5-fpm.sock;  
            fastcgi_index index.php;  
            include fastcgi_params;  
    }  
    client_max_body_size 8M;  

}


#2

@wayne

Please share link to your site/URL where you see 404.

Also, are you using multisite with subdomains OR subdirectories?

Most likely "map" feature will not be needed after WordPress 3.5 version which I think will release this week only.


#3

Thank you for the reply Rahul. I realized my mistake shortly after I broke down and posted for help. My box is waiting for 3.5 to drop. I would like to hear your opinions on 3.5 and what, if anything is going to change regarding your plugin and the differences between choosing sub directories vs. sub domains. Thank you for the detailed write up. Very helpful.

Wayne


#4

@Wayne

For Multisite WordPress few rules need to be removed but nothing will be added for sure.

Also, old WordPress multisite setup, which will upgrade to WordPress 3.5 may need old rules. I will verify once new WordPress 3.5 is out.

In any case, lines which may become "extras" won't harm or break anything.


#5

Update: All our wordpress-nginx config are updated for WordPress 3.5. You can find them here - http://rtcamp.com/wordpress-nginx/tutorials


#6