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've trouble to get aliases working correctly on nginx. When i try to access the aliases, /pma and /mba (see, i get a 403 Forbidden but the base url works correctly.

I read a lot of posts but nothing helped, so here i am.

Nginx and php-fpm are running as www-data:www-data and the permissions for the directories are set to:

drwxrwsr-x+  5 www-data www-data 4.0K Dec  5 22:48 ./
drwxr-xr-x.  3 root     root     4.0K Dec  4 22:50 ../
drwxrwsr-x+  2 www-data www-data 4.0K Dec  5 13:10
drwxrwsr-x+ 11 www-data www-data 4.0K Dec  5 10:34
drwxrwsr-x+  3 www-data www-data 4.0K Dec  5 11:49
lrwxrwxrwx.  1 www-data www-data   18 Dec  5 09:56 ->

Im sorry for the bulk, but i thought better too much than too little.

Here are the configuration files:


user              www-data www-data;
worker_processes  1;

error_log   /var/log/nginx/error.log;
#error_log  /var/log/nginx/error.log  notice;
#error_log  /var/log/nginx/error.log  info;

pid         /var/run/;

events {
    worker_connections  1024;

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

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

    sendfile        on;
    keepalive_timeout  65;

    include /etc/nginx/sites-enabled/*;



server {
    listen          80;
    return          301 https://$host$request_uri;

server {
    listen          443;

    access_log      /var/log/nginx/;
    error_log       /var/log/nginx/;

    root            /srv/http/;

    include         /etc/nginx/ssl/;
    include         /etc/nginx/conf.d/index.conf;
    include         /etc/nginx/conf.d/php-ssl.conf;

    autoindex       off;

    location /pma/ {
        alias       /srv/http/;

    location /mda/ {
        alias       /srv/http/;


ssl                 on;
ssl_certificate     /etc/nginx/ssl/;
ssl_certificate_key /etc/nginx/ssl/;
ssl_protocols       SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers         HIGH:!aNULL:!MD5;


index   index.php index.html index.htm;


location ~ \.php$ {
    try_files       $uri =404;
    fastcgi_pass    unix:/var/run/php-fpm/php-fpm.sock;
    fastcgi_index   index.php;
    fastcgi_param   HTTPS on;
    fastcgi_param   SCRIPT_FILENAME  $request_filename;
    include         fastcgi_params;


2013/12/05 22:49:04 [error] 29291#0: *2 directory index of "/srv/http/" is forbidden, client:, server:, request: "GET /pma/ HTTP/1.1", host: ""

EDIT: forgot to mention, i'm running CentOS 6.4 x86_64 and nginx 1.0.15

Thanks in advance!

share|improve this question
up vote 0 down vote accepted

You have your /pma and /mda in a non standard location (for CentOS) in /srv/http the problems you're seeing could be related to SELinux.

A quick test is to configure SELinux for permissive mode

setenforce 0

Test to see if your pages work correctly. If they do then you need to configure the correct context for /srv/http

semanage fcontext -a -t httpd_sys_content_t "/srv/httpd(/.*)?"
restorecon -rv /srv/http
setenforce 1

Test again and hopefully you're good to go.

share|improve this answer
Thank you for answering! I set SELiunx to permissive and after that didn't work i also disabled it, but I still get the 403. The error log says nginx tries directory listing and that is the reason why i get the 403 but nginx shouldn't even try because i set the index to index.php index.html. I also tried to set the index again in the location section of /pma and /mda but it's also being ignored. Furthermore i tried adding index.php to the end of the URL (/pma/index.php) and then i got a 404. – michell90 Dec 6 '13 at 13:31
@michell90: Have you checked the permissions of the files in /srv/http and of the /srv and /srv/httpd directories to ensure that nginx can read the files and read/execute the directories at some level ? – Iain Dec 6 '13 at 13:40
@lain Yes, the permissions shown at the top of my post are set recursively with chmod and chown. I changed my configuration again and deleted the "/" at the end of the alias, now it looks like: location /pma. Now it processes index.html correctly, but when it comes to an php file i still get the 404. So now the problem seems to be my php-fpm. But i don't understand why nginx behave like this, also i'm pretty sure i already tried this and earlier it didn't work. I'm a bit confused right now. Btw: I get the same behavior at my worksation where i run ArchLinux. – michell90 Dec 6 '13 at 14:43

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.