# Problem with MediaWiki File page

**URL:** <https://www.ruby-forum.com/t/problem-with-mediawiki-file-page/212087>\
**Category:** NGINX\
**Created:** [September 21, 2011, 10:44pm UTC](https://www.ruby-forum.com/t/problem-with-mediawiki-file-page/212087 "2011-09-21T22:44:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [September 21, 2011, 10:44pm UTC](https://www.ruby-forum.com/t/problem-with-mediawiki-file-page/212087/1 "2011-09-21T22:44:52Z")

</div>

HI,

I have following nginx configuration for a MediaWiki based site

server {  
listen 174.36.130.243:80;  
server\_name [webhostingneeds.com](http://webhostingneeds.com) [www.webhostingneeds.com](http://www.webhostingneeds.com);

```
    location ~* \.(js|css|rdf|xml|ico|txt|gif|jpg|png|jpeg|html)$ {
    root /home/webhost/public_html/;
    access_log /var/log/nginx/webhostingneeds.com_static.log;
    }

    location / {
        proxy_pass http://174.36.130.243:81/;
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For 

```

$proxy\_add\_x\_forwarded\_for;  
client\_max\_body\_size 1m;  
client\_body\_buffer\_size 128k;  
proxy\_connect\_timeout 90;  
proxy\_send\_timeout 90;  
proxy\_read\_timeout 90;  
proxy\_buffer\_size 4k;  
proxy\_buffers 4 32k;  
proxy\_busy\_buffers\_size 64k;  
proxy\_temp\_file\_write\_size 64k;  
}  
}

The problem is when a file is uploaded to MediaWIki, i shows a page like

[http://webhostingneeds.com/File:FILENAME.exten](http://webhostingneeds.com/File:FILENAME.exten)

For example

[http://webhostingneeds.com/File:Averttv\_device\_property.jpg](http://webhostingneeds.com/File:Averttv_device_property.jpg)

Since the file extension is .jpg, nginx try to service this as static  
content.

How i can set nginx to serve static files, pass anything starting with  
/File: to apache ?

Thanks,

Santhosh

---

<div class="post-metadata">

**Author:** ![BizHat.com\_Support](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ac91a4/32.png) [@BizHat.com\_Support](https://www.ruby-forum.com/u/BizHat.com_Support)\
**Post date:** [September 22, 2011, 1:30pm UTC](https://www.ruby-forum.com/t/problem-with-mediawiki-file-page/212087/2 "2011-09-22T13:30:44Z")

</div>

On Thu, Sep 22, 2011 at 02:14:04AM +0530, [BizHat.com](http://BizHat.com) Support wrote:

Hi there,

> ```
> location ~* \.(js|css|rdf|xml|ico|txt|gif|jpg|png|jpeg|html)$ {
> root /home/webhost/public_html/;
> access_log /var/log/nginx/webhostingneeds.com_static.log;
> }
> 
> ```

> ```
> location / {
> proxy_pass http://174.36.130.243:81/;
> 
> ```

(plus extra proxy settings)

> ```
> }
> 
> ```

> How i can set nginx to serve static files, pass anything starting with  
> /File: to apache ?

nginx configuration is based on location blocks. One request is handled  
by one location.

Details at [GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com · GitHub](http://wiki.nginx.org/HttpCoreModule#location)

Your current config has one location for urls that match a regex, such  
that they end in one of 11 specific strings; plus one location for  
everything else.

You want a new location for urls that start with one specific string,  
and you want regex locations not to be tested if this location matches.

So do exactly that:

location ^~ /File: {  
}

and inside that location block, put your full proxy\_pass and other  
relevant configuration.

All the best,

## f

Francis D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![BizHat.com\_Support](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ac91a4/32.png) [@BizHat.com\_Support](https://www.ruby-forum.com/u/BizHat.com_Support)\
**Post date:** [September 22, 2011, 3:45pm UTC](https://www.ruby-forum.com/t/problem-with-mediawiki-file-page/212087/3 "2011-09-22T15:45:50Z")

</div>

On 21 Set 2011 21h44 WEST, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> root /home/webhost/public\_html/;  
> client\_body\_buffer\_size 128k;  
> The problem is when a file is uploaded to MediaWIki, i shows a page  
> like
> 
> [http://webhostingneeds.com/File:FILENAME.exten](http://webhostingneeds.com/File:FILENAME.exten)

This should work:

location / {

```
proxy_pass http://174.36.130.243:81/;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 1m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;

location ^~ /File: {

    location ~* /File:[^/]*\.(?:jpe?g|png|gif|html)$ {
        proxy_pass http://174.36.130.243:81/;
    }
}

```

}

> For example
> 
> [http://webhostingneeds.com/File:Averttv\_device\_property.jpg](http://webhostingneeds.com/File:Averttv_device_property.jpg)
> 
> Since the file extension is .jpg, nginx try to service this as  
> static content.
> 
> How i can set nginx to serve static files, pass anything starting  
> with /File: to apache ?

— appa
