# NGINX config multi site Image are not displaying on Sub domains

**URL:** <https://www.ruby-forum.com/t/nginx-config-multi-site-image-are-not-displaying-on-sub-domains/199782>\
**Category:** NGINX\
**Created:** [November 29, 2010, 9:56am UTC](https://www.ruby-forum.com/t/nginx-config-multi-site-image-are-not-displaying-on-sub-domains/199782 "2010-11-29T09:56:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [November 29, 2010, 9:56am UTC](https://www.ruby-forum.com/t/nginx-config-multi-site-image-are-not-displaying-on-sub-domains/199782/1 "2010-11-29T09:56:52Z")

</div>

I don’t know is the is anybody who can help me I need an expert advice  
or somebody who encountered this problem. Here is a problem can’t figer  
out what is the problem with my set up.

Problem@@@\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_

Images on sub domains are not displaying properly the main domain images  
are working.  
I don’t know if the is an options in wp I am not awere of or it is my  
setup

* * *

Below are my nginx config

RUNNING NGINX+FASTCGI ON DEBIAN.  
\_

server{  
server\_name \*.mysite.com [mysite.com](http://mysite.com) [http://www.mysite.com](http://www.mysite.com);  
listen 80;  
#on server block  
##necessary if using a multi-site plugin  
server\_name\_in\_redirect off;  
##necessary if running Nginx behind a reverse-proxy  
port\_in\_redirect off;  
access\_log /var/log/nginx/localhost.access.log;

location / {  
root /var/www/mysite;  
index index.html index.htm index.php;

# if the requested file exists, return it immediately

if (-f $request\_filename) {  
break;  
}

## W3 Total CACHE BEGIN

set $totalcache\_file ‘’;  
set $totalcache\_uri $request\_uri;

if ($request\_method = POST) {  
set $totalcache\_uri ‘’;  
}

# Using pretty permalinks, so bypass the cache for any query string

if ($query\_string) {  
set $totalcache\_uri ‘’;  
}

if ($http\_cookie ~\* “comment\_author\_|wordpress|wp-postpass\_” ) {  
set $totalcache\_uri ‘’;  
}

# if we haven’t bypassed the cache, specify our totalcache file

if ($totalcache\_uri ~ ^(.+)$) {  
set $totalcache\_file /wp-content/w3tc-$http\_host/pgcache/$1/\_index.html;  
}

# only rewrite to the totalcache file if it actually exists

if (-f $document\_root$totalcache\_file) {  
rewrite ^(.\*)$ $totalcache\_file break;  
}

##W3 Total CACHE END

# all other requests go to WordPress

if (!-e $request\_filename) {  
rewrite . /index.php last;  
}  
}

## Images and static content is treated different

location ~\* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {  
access\_log off;  
expires 30d;  
root /var/www/mysite;  
}

location ~ .php$ {  
include /usr/local/nginx/conf/fastcgi\_params;  
fastcgi\_pass 127.0.0.1:9000;  
fastcgi\_index index.php;  
fastcgi\_param SCRIPT\_FILENAME /var/www/mysite$fastcgi\_script\_name;  
}  
}

* * *

Everything else is default  
[http://subdomain.main.com/files/2010/11/5537445.jpg](http://subdomain.main.com/files/2010/11/5537445.jpg)  
Links to images are as follows  
and blogs.dir folder

I think the is a error in my

location ~\* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {  
access\_log off;  
expires 30d;  
root /var/www/mysite;  
}

If anybody have a solution it will be really appreciated.

---

<div class="post-metadata">

**Author:** ![orlick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/53a042/32.png) [@orlick](https://www.ruby-forum.com/u/orlick)\
**Post date:** [November 29, 2010, 1:11pm UTC](https://www.ruby-forum.com/t/nginx-config-multi-site-image-are-not-displaying-on-sub-domains/199782/2 "2010-11-29T13:11:51Z")

</div>

Hello!

On Mon, Nov 29, 2010 at 09:56:52AM +0100, Alex Kolobok wrote:

> * * *
> 
> Below are my nginx config

[…]

> ## Images and static content is treated different
> 
> location ~\* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {  
> access\_log off;  
> expires 30d;  
> root /var/www/mysite;  
> }

You explicitly instructed nginx to look for images (and other  
static files) under /var/www/mysite. There is no surprise it does  
what you said to.

Maxim D.

---

<div class="post-metadata">

**Author:** ![orlick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/53a042/32.png) [@orlick](https://www.ruby-forum.com/u/orlick)\
**Post date:** [November 29, 2010, 2:02pm UTC](https://www.ruby-forum.com/t/nginx-config-multi-site-image-are-not-displaying-on-sub-domains/199782/3 "2010-11-29T14:02:26Z")

</div>

I am sorry so what would be my solution for this problem what would be  
the correct configuration

All of the images located in the  
++blogs.dir++ each newly created blog is assign a number \>

I have just checked the direct link  
[http://subdomain.main.com/wp-content/blogs.dir/135/files/2010/11/file11.jpg](http://subdomain.main.com/wp-content/blogs.dir/135/files/2010/11/file11.jpg)  
image displaying so it is some were in the path.

How would I rewrite this or else what would be the rational decision for  
that config.

Sincerely,

---

<div class="post-metadata">

**Author:** ![orlick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/53a042/32.png) [@orlick](https://www.ruby-forum.com/u/orlick)\
**Post date:** [November 29, 2010, 3:09pm UTC](https://www.ruby-forum.com/t/nginx-config-multi-site-image-are-not-displaying-on-sub-domains/199782/4 "2010-11-29T15:09:33Z")

</div>

Got it

rewrite ^._/files/(._)$ /wp-includes/ms-files.php?file=$1 last;  
if (!-e $request\_filename) {

Instead !!!

Sincerely,
