Bugzilla + Node.js with nginx - rest service not working

0

I've setup my server so that is serve both node.js and bugzilla on port 8080 with nginx reverse proxy.

Node.js site responds to url http://example.com/ Bugzilla to url http://example.com/bugzilla

Everything works fine, except the bugzilla rest api (e.g http://example.com/rest.cgi/bug). I always get 403 forbidden and on server log, the following error:

[error] 9049#9049: *83 FastCGI sent in stderr: "Cannot get script name, are DOCUMENT_ROOT and SCRIPT_NAME (or SCRIPT_FILENAME) set and is the script executable?" while reading response header from upstream, client: 93.36.171.43, server: _, request: "GET /bugzilla/rest.cgi/bug HTTP/1.1", upstream: "fastcgi://unix:/var/run/fcgiwrap.socket:", host: "factory.quiddis.com" 

My nginx config file looks like this:

server { 

        listen 80 default_server; 
        listen [::]:80 default_server; 

        root /var/www/html; 

        index index.html index.htm index.php index.cgi; 

        fastcgi_buffers 8 16k; 
        fastcgi_buffer_size 32k; 

        client_max_body_size 24M; 
        client_body_buffer_size 128k; 

        server_name _; 

        # This configuration is open under mydomain.com 
        location / { 
                proxy_pass http://localhost:8080; 
                proxy_http_version 1.1; 
                proxy_set_header Upgrade $http_upgrade; 
                proxy_set_header Connection 'upgrade'; 
                proxy_set_header Host $host; 
                proxy_cache_bypass $http_upgrade; 
        } 

        # This configuration is open under mydomain.com/myapp 
        location /bugzilla { 
                # alias /home/apps/myapp; 
                try_files $uri $uri/ /index.cgi$is_args$args; 
        } 

        location ~ \.php$ { 
                # If php is updated, should update the fpm php version 
                include snippets/fastcgi-php.conf; 
                fastcgi_pass unix:/run/php/php7.2-fpm.sock; 
        } 
        location ~ /\.ht { 
                deny all; 
        } 

        location ~ ^.*\.cgi$ { 
                include /etc/nginx/fastcgi_params; 
                fastcgi_pass  unix:/var/run/fcgiwrap.socket; 
                fastcgi_index index.cgi; 
                fastcgi_param SCRIPT_FILENAME /$document_root/$fastcgi_script_name; 
        } 

} 

I think the relevant part is here:

location ~ ^.*\.cgi$ { 
        include /etc/nginx/fastcgi_params; 
        fastcgi_pass  unix:/var/run/fcgiwrap.socket; 
        fastcgi_index index.cgi; 
        fastcgi_param SCRIPT_FILENAME /$document_root/$fastcgi_script_name; 
} 

beacuse the .cgi file is followed by "/bug" (or any other parameter like api key etc) and perhaps it is not correctly split into parts. Thanks in advance for any help!

lviggiani

Posted 2019-06-20T07:38:53.807

Reputation: 221

No answers