0

I am running Nginx server on Debian 9. My problem is that, Nginx is serving Perl files in root directory, but it is not serving in alias directory (I get 403 Forbidden).

This is my configuration of alias:

    include /etc/nginx/fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

    server {
        listen   80;

        server_name www.example.tld example.tld;
        root /srv/!example.tld/!www;
        index  desktop.pl index.html index.htm core.tom core.pl;

        location /my_alias {

            alias /srv/!example.tld/my_alias/!www;

            location ~ /my_alias/\.pl$ {
                gzip off;
                fastcgi_pass unix:/var/run/fcgiwrap.socket;
            }
        }

        location ~ \.pl$ {
            gzip off;
            fastcgi_pass unix:/var/run/fcgiwrap.socket;
        }
    }

I really don't know what is wrong with it.

Everything what I want is to execute Perl files on whole server (all aliases), ideal is to execute Perl files on ALL sites (virtualhosts).

tomsk
  • 287
  • 1
  • 6
  • 18
  • Your regexp is wrong – Alexey Ten Sep 22 '17 at 17:27
  • Please what is wrong with it? – tomsk Sep 22 '17 at 18:06
  • 1
    It matches exactly one file: `.pl`. You’ve missed `.*` part of regexp – Alexey Ten Sep 22 '17 at 18:08
  • But I have this block `location ~ \.pl$ {` at root level and it works, and there is no `.*`, so what do you mean? – tomsk Sep 22 '17 at 18:36
  • If you have a `location ~ \.pl$` block in the root of your configuration, you should show it in your question as it will have an effect. `$document_root$fastcgi_script_name` will not work with `alias` - you should use `$request_filename`. – Richard Smith Sep 22 '17 at 20:15
  • I updated question, I added whole configuration, everything what I want is to execute Perl files on whole server (all aliases), ideal is to execute Perl files on ALL sites (virtualhosts). – tomsk Sep 22 '17 at 21:45

0 Answers0