Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 some problems with nginx with some location config, here is my config file:

user  dev-ci;

location ~* /img/screenshots/ {
    alias /dev/shm/screenshots/;

# other location with root and proxing to apache currently working propertly

My petition with browser is:


My nginx log is:

2012/04/23 08:49:40 [error] 13916#0: *2148 directory index of "/dev/shm/screenshots/" is forbidden, client: *.*.*.5, server: development, request: "GET /img/screenshots/4336.jpg/?id=85574 HTTP/1.1", host: "****"

My ls -la from directory /dev/shm/screenshots/:

drwxrwxrwx  3 dev-ci dev-ci   80 2012-04-23 08:54 .
drwxrwxrwt 11 root   root    260 2012-04-23 07:27 ..
-rw-r--r--  1 dev-ci dev-ci 7450 2012-04-23 08:54 4336.jpg
drwxrwxrwx  2 root   root     40 2012-04-23 07:25 errors

The nginx user running is: dev-ci (here we can see the ps aux | grep nginx)

root      1231  0.0  0.0  22052  1432 ?        Ss   07:25   0:00 nginx: master process /usr/local/nginx/sbin/nginx
dev-ci   13916  0.0  0.0  22448  1760 ?        S    08:48   0:00 nginx: worker process      

Any idea why isn't working? I get 403 Forbidden error directly to nginx, so the first location is working, but it doesn't alias correctly. The nginx process has the same username as the file, the directory has 777, I tried to change the owner and group to dev-ci user with the same result. I need a bright idea, and soon...


share|improve this question

You're not using location properly - it appears you're trying to use regex improperly.

location /img/screenshots/ {
    alias /dev/shm/screenshots/;

This should work fine.

For further reference, see

share|improve this answer
sorry it doesn't work, I get not found from nginx because it gets from other location, not from the location we are working. – enedebe Apr 23 '12 at 9:25
Read how to use location (order is important) – AlexD Apr 23 '12 at 9:49
Did you try using root instead of alias? Also I've noticed there's a slash after .jpg - could you post the entire config? If you're using a rewrite, that could be causing the problem. – Sašo Apr 26 '12 at 7:39

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.