WordPress.org

Ready to get started?Download WordPress

Forums

Nginx + Multisite doesn't show uploaded images (3 posts)

  1. dallasb86
    Member
    Posted 1 year ago #

    I have Nginx set up as a reverse proxy on my VPS. I also have a WordPress multisite installation set up. Everything works just fine except for the uploaded images. I can create new sites and I can upload images to those site but the images don't display in the backend or on the frontend.

    Here is the site config for Nginx:

    map $http_host $blogid {
            default	  -999;
            include /home/cpress/public_html/wp-content/plugins/nginx-helper/map.conf;
        }
    
        server {
                  error_log /var/log/nginx/vhost-error_log warn;
                  listen server.ip.address:80;
                  server_name site.com www.site.com *.site.com;
                  access_log /usr/local/apache/domlogs/site.com-bytes_log bytes_log;
                  access_log /usr/local/apache/domlogs/site.com combined;
                  root /home/cpress/public_html;
                  index index.php index.html index.htm;
    
                  location / {
                  location ~.*\.(3gp|gif|jpg|jpeg|png|ico|wmv|avi|asf|asx|mpg|mpeg|mp4|pls|mp3|mid|wav|swf|flv|html|htm|txt|js|css|exe|zip|tar|rar|gz|tgz|bz2|uha|7z|doc|docx|xls|xlsx|pdf|iso)$ {
                  expires 30d;
                  try_files $uri  $uri/ /index.php?$args;
                  }
    
                  rewrite /wp-admin$ $scheme://$host$uri/ permanent;
    
                  error_page 405 = @backend;
                  add_header X-Cache "HIT from Backend";
                  proxy_pass http://server.ip.address:8081;
                  include proxy.inc;
                  }
                  location @backend {
                  internal;
                  proxy_pass http://server.ip.address:8081;
                  include proxy.inc;
                  }
                  location ~ .*\.(php|jsp|cgi|pl|py)?$ {
                  proxy_pass http://server.ip.address:8081;
                  include proxy.inc;
                  }
                  location ~ /\.ht {
                  deny all;
                  }
    
        location ~ \.php$ {
                  try_files $uri @wordpress;
                  proxy_set_header Host $host;
                  proxy_set_header X-Real-IP $remote_addr;
                  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                  proxy_pass   http://server.ip.address:8081;
                  }
    
        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;
                  }
    
        location ^~ /blogs.dir {
                  internal;
                  alias /home/cpress/public_html/wp-content/blogs.dir;
                  access_log off; log_not_found off; expires max;
                  }
        }
  2. coreutils
    Member
    Posted 1 year ago #

    Hi, dallasb86

    It is weird, I got the same result.
    I followed the instruction here: http://codex.wordpress.org/Nginx
    Since we are still using wordpress 2.8 and the ngix-helper plugin is not compatible, I even manually create the map file. But the picture just not show up. I switched from apache to ngnix and I am still struggling ...

    Is there anybody could help?

  3. coreutils
    Member
    Posted 1 year ago #

    Oops, problem solved!
    I am using wordpress 2.8 and the plugin handle image file is not exist (ms-files.php)
    I have to use this directive instead:
    rewrite ^.*/files/(.*) /wp-content/blogs.php?file=$1;

    if you follow the http://codex.wordpress.org/Nginx, please replace

    location ~ ^/[_0-9a-zA-Z-]+/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;
    }

    with the one above.

    Good luck!

Topic Closed

This topic has been closed to new replies.

About this Topic