Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Perl + nginx 403 errors again

Tags:

nginx

perl

It seems a never ending battle getting Perl and nginx playing nice :( I've setup a new dev server. I wont bore you with all of the details, but suffice to say I have installed (via apt-get);

sudo apt-get update && sudo apt-get upgrade
sudo apt-get install nginx
sudo apt-get install php5-cli php5-cgi spawn-fcgi php-pear
sudo apt-get install mysql-server php5-mysql
sudo apt-get install fcgiwrap

I have then configured my site, using:

server {

    listen   80;

    server_name site.net.net www.site.net.net;
    access_log /srv/www/site.net.net/logs/access.log;
    error_log /srv/www/site.net.net/logs/error.log;
    root /srv/www/site.net.net/www;

 location / {
        index  index.html index.htm;
    }

    location ~ \.php$ {
        try_files $uri =404;
        include /etc/nginx/fastcgi_params;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /srv/www/site.net.net/www$fastcgi_script_name;
    }

    location ~ \.cgi$ {
            try_files $uri =404;
            gzip off;
            include /etc/nginx/fastcgi_params;
            fastcgi_pass unix:/var/run/fcgiwrap.socket;
            fastcgi_index index.cgi;
            fastcgi_param SCRIPT_FILENAME /srv/www/site.net.net/www/cgi-bin/$fastcgi_script_name;
        }

}

I've sym-linked the config files into sites-enabled, so that its visible on nginx. I then rebooted nginx, and tried:

index.html - works fine
index.php - works fine
index.cgi - 403 error

I managed to fumble my way through it last time, but I can't figure out what I did different (I know it was a real pig to get configured the first time around)

The only thing showing in the error_log, is:

2015/07/31 15:52:25 [error] 10434#0: *7 open() "/srv/www/site.net/www/favicon.ico" failed (2: No such file or directory), client: 81.174.134.xx, server: sitenet, request: "GET /favicon.ico HTTP/1.1", host: "site.net"

So not much help :/

Any suggestions from the experts?

UPDATE:

If I update the error log to "debug" level, i.e:

error_log /srv/www/steampunkjunkiesdev.net/logs/error.log debug;

...below is what is outputted (from just 1 request). Not sure if there is anything helpful in there though?

Server: nginx/1.6.2
Date: Fri, 31 Jul 2015 15:11:49 GMT
Content-Type: text/html
Transfer-Encoding: chunked
Connection: keep-alive
Content-Encoding: gzip

2015/07/31 16:11:49 [debug] 3557#0: *1 write new buf t:1 f:0 0000000000F049D8, pos 0000000000F049D8, size: 185 file: 0, size: 0
2015/07/31 16:11:49 [debug] 3557#0: *1 http write filter: l:0 f:0 s:185
2015/07/31 16:11:49 [debug] 3557#0: *1 http output filter "/favicon.ico?"
2015/07/31 16:11:49 [debug] 3557#0: *1 http copy filter: "/favicon.ico?"
2015/07/31 16:11:49 [debug] 3557#0: *1 image filter
2015/07/31 16:11:49 [debug] 3557#0: *1 xslt filter body
2015/07/31 16:11:49 [debug] 3557#0: *1 http postpone filter "/favicon.ico?" 0000000000F04AF8
2015/07/31 16:11:49 [debug] 3557#0: *1 http gzip filter
2015/07/31 16:11:49 [debug] 3557#0: *1 malloc: 0000000000EED690:12288
2015/07/31 16:11:49 [debug] 3557#0: *1 gzip alloc: n:1 s:5936 a:8192 p:0000000000EED690
2015/07/31 16:11:49 [debug] 3557#0: *1 gzip alloc: n:512 s:2 a:1024 p:0000000000EEF690
2015/07/31 16:11:49 [debug] 3557#0: *1 gzip alloc: n:512 s:2 a:1024 p:0000000000EEFA90
2015/07/31 16:11:49 [debug] 3557#0: *1 gzip alloc: n:512 s:2 a:1024 p:0000000000EEFE90
2015/07/31 16:11:49 [debug] 3557#0: *1 gzip alloc: n:256 s:4 a:1024 p:0000000000EF0290
2015/07/31 16:11:49 [debug] 3557#0: *1 gzip in: 0000000000EF6EE8
2015/07/31 16:11:49 [debug] 3557#0: *1 gzip in_buf:0000000000F04AA8 ni:00000000006DC600 ai:116
2015/07/31 16:11:49 [debug] 3557#0: *1 malloc: 0000000000EF06A0:4096
2015/07/31 16:11:49 [debug] 3557#0: *1 deflate in: ni:00000000006DC600 no:0000000000EF06A0 ai:116 ao:4096 fl:0 redo:0
2015/07/31 16:11:49 [debug] 3557#0: *1 deflate out: ni:00000000006DC674 no:0000000000EF06A0 ai:0 ao:4096 rc:0
2015/07/31 16:11:49 [debug] 3557#0: *1 gzip in_buf:0000000000F04AA8 pos:00000000006DC600
2015/07/31 16:11:49 [debug] 3557#0: *1 gzip in: 0000000000EF6EF8
2015/07/31 16:11:49 [debug] 3557#0: *1 gzip in_buf:0000000000EF6E20 ni:00000000006DCDA0 ai:52
2015/07/31 16:11:49 [debug] 3557#0: *1 deflate in: ni:00000000006DCDA0 no:0000000000EF06A0 ai:52 ao:4096 fl:4 redo:0
2015/07/31 16:11:49 [debug] 3557#0: *1 deflate out: ni:00000000006DCDD4 no:0000000000EF0711 ai:0 ao:3983 rc:1
2015/07/31 16:11:49 [debug] 3557#0: *1 gzip in_buf:0000000000EF6E20 pos:00000000006DCDA0
2015/07/31 16:11:49 [debug] 3557#0: *1 free: 0000000000EED690
2015/07/31 16:11:49 [debug] 3557#0: *1 http chunk: 10
2015/07/31 16:11:49 [debug] 3557#0: *1 http chunk: 121
2015/07/31 16:11:49 [debug] 3557#0: *1 write old buf t:1 f:0 0000000000F049D8, pos 0000000000F049D8, size: 185 file: 0, size: 0
2015/07/31 16:11:49 [debug] 3557#0: *1 write new buf t:1 f:0 0000000000EF7058, pos 0000000000EF7058, size: 4 file: 0, size: 0
2015/07/31 16:11:49 [debug] 3557#0: *1 write new buf t:0 f:0 0000000000000000, pos 00000000006E0240, size: 10 file: 0, size: 0
2015/07/31 16:11:49 [debug] 3557#0: *1 write new buf t:1 f:0 0000000000EF06A0, pos 0000000000EF06A0, size: 121 file: 0, size: 0
2015/07/31 16:11:49 [debug] 3557#0: *1 write new buf t:0 f:0 0000000000000000, pos 00000000004B2EB8, size: 7 file: 0, size: 0
2015/07/31 16:11:49 [debug] 3557#0: *1 http write filter: l:1 f:1 s:327
2015/07/31 16:11:49 [debug] 3557#0: *1 http write filter limit 0
2015/07/31 16:11:49 [debug] 3557#0: *1 writev: 327
2015/07/31 16:11:49 [debug] 3557#0: *1 http write filter 0000000000000000
2015/07/31 16:11:49 [debug] 3557#0: *1 http copy filter: 0 "/favicon.ico?"
2015/07/31 16:11:49 [debug] 3557#0: *1 http finalize request: 0, "/favicon.ico?" a:1, c:1
2015/07/31 16:11:49 [debug] 3557#0: *1 set http keepalive handler
2015/07/31 16:11:49 [debug] 3557#0: *1 http close request
2015/07/31 16:11:49 [debug] 3557#0: *1 http log handler
2015/07/31 16:11:49 [debug] 3557#0: *1 free: 0000000000EF06A0
2015/07/31 16:11:49 [debug] 3557#0: *1 free: 0000000000000000
2015/07/31 16:11:49 [debug] 3557#0: *1 free: 0000000000F03B20, unused: 8
2015/07/31 16:11:49 [debug] 3557#0: *1 free: 0000000000EF6A40, unused: 2156
2015/07/31 16:11:49 [debug] 3557#0: *1 free: 0000000000F09E70
2015/07/31 16:11:49 [debug] 3557#0: *1 hc free: 0000000000000000 0
2015/07/31 16:11:49 [debug] 3557#0: *1 hc busy: 0000000000000000 0
2015/07/31 16:11:49 [debug] 3557#0: *1 reusable connection: 1
2015/07/31 16:11:49 [debug] 3557#0: *1 event timer add: 14: 65000:1438355574073
2015/07/31 16:11:49 [debug] 3557#0: *1 post event 0000000000F4A118
2015/07/31 16:11:49 [debug] 3557#0: *1 delete posted event 0000000000F4A118
2015/07/31 16:11:49 [debug] 3557#0: *1 http keepalive handler
2015/07/31 16:11:49 [debug] 3557#0: *1 malloc: 0000000000F09E70:1024
2015/07/31 16:11:49 [debug] 3557#0: *1 recv: fd:14 -1 of 1024
2015/07/31 16:11:49 [debug] 3557#0: *1 recv() not ready (11: Resource temporarily unavailable)
2015/07/31 16:11:49 [debug] 3557#0: *1 free: 0000000000F09E70
like image 535
Andrew Newby Avatar asked Jan 21 '26 16:01

Andrew Newby


1 Answers

Eugh, I feel like a total idiot now! In my config, I had:

location ~ \.cgi$ {
    gzip off;
    include /etc/nginx/fastcgi_params;
    fastcgi_pass unix:/var/run/fcgiwrap.socket;
    fastcgi_index index.cgi;
    fastcgi_param SCRIPT_FILENAME /srv/www/site.net/www/cgi-bin$fastcgi_script_name;
}

However, that SCRIPT_FILENAME was wrong... should be:

location ~ \.cgi$ {
    gzip off;
    include /etc/nginx/fastcgi_params;
    fastcgi_pass unix:/var/run/fcgiwrap.socket;
    fastcgi_index index.cgi;
    fastcgi_param SCRIPT_FILENAME /srv/www/site.net/www/$fastcgi_script_name;
}

(notice the missing /cgi-bin on the 2nd to last line). So simple when you can see it! Just thought I'd share it, with the hope it will help someone else out at some point in the future. Duh!

like image 147
Andrew Newby Avatar answered Jan 23 '26 07:01

Andrew Newby



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!