1

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_pass         http://127.0.0.1:8080;
            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 website.com/static/*.png

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

2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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