Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a server:

server {

    listen   80; ## listen for ipv4
    listen   [::]:80 default ipv6only=on; ## listen for ipv6

    access_log  /var/log/nginx/localhost.access.log;

    location ~* \.(png|ico)$ {
         root /home/anatoly/gyazo;

          location / {
            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;


Now my static content (some pictures) is availible on the root of website, but how can I configure nginx to make static content availible on specific url? For example*.png

I found the rewrite command in nginx documentation but I'm not able to use it.

share|improve this question
up vote 2 down vote accepted

If I understand this correctly, you're looking for alias.

location /static/ {
    alias /home/anatoly/gyazo;

Unless you want to hide non .png and .ico files, this should be perfectly fine.

share|improve this answer
exactly what i needed, thanks! – Korniltsev Anatoly Apr 29 '12 at 0:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.