Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

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

110 views
Skip to first unread message

luca.v...@grammelot.eu

unread,
Jun 20, 2019, 3:13:44 AM6/20/19
to
Hi, I've setup my server so that is server 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 forobidden 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!

Thorsten Schöning

unread,
Jun 20, 2019, 4:33:35 AM6/20/19
to support-...@lists.mozilla.org
Guten Tag luca.v...@grammelot.eu,
am Donnerstag, 20. Juni 2019 um 09:13 schrieben Sie:

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

Are sure about that? As I understand your config, only the domain
itself and hence Node.js is forwarded to :8080, which makes sense,
because Bugzilla doesn't have a listening server. Additionally, both
apps listening on the same localhost:8080 doesn't make much sense as
well. How would both be distinguished from each other?

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

Forbidden make sense because your location-block enabling FastCGI
simply doesn't match your URL. That block requires to end with ".cgi",
which is not the case for your requests.

> [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"

Not sure where those messages come from, but with my very limited
knowledge about nginx I suspect(!) that by default you have miltiple
FastCGI-servers running. The one you explicitly configure with your
last location-block, but which is not used in my opinion because of
the wrong URL, and maybe some other one because of the
fastcgi_*-configs outside of that location block and that one might be
used for some requests.

How sure are you that 403 FORBIDDEN and the error messages from
FastCGI are really related to your request toe Bugzilla's REST-API? It
might be that both are not related, but instead you get a 403
FORBIDDEN and the error messages from FastCGI come from implicit
requests of some web client to things like favicon.ico or stuff like
that.

> 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;
> }

Simply comment that location for test purposes and don't use FastCGI
first. It only improves performance, which you don't need to care
until things work at all.

Besides that, in my opinion that block doesn't match your REST-request
at all, because those end with ".cgi". I don't think the problem is
with splitting anything by nginx. Instead, the regular expression for
the location itself needs to be changed to something like the
following:

> location ~ ^.*\.cgi.*$
> location ~ ^.*\.cgi(?:/.+)?$

The second one seems more correct, but not sure if reg exp-engine of
nginx supports that.

Mit freundlichen Grüßen,

Thorsten Schöning

--
Thorsten Schöning E-Mail: Thorsten....@AM-SoFT.de
AM-SoFT IT-Systeme http://www.AM-SoFT.de/

Telefon...........05151- 9468- 55
Fax...............05151- 9468- 88
Mobil..............0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow

luca.v...@grammelot.eu

unread,
Jun 20, 2019, 4:38:39 AM6/20/19
to
Hi, thanks for your support!
in the mean time I came to the same conclusion and could fix it like that:

location /bugzilla/rest {
rewrite ^/bugzilla/rest/(.*)$ /bugzilla/rest.cgi/$1 last;
}

location ~ \.cgi {
include fastcgi_params;
fastcgi_param SCRIPT_NAME '';
fastcgi_param PATH_INFO $uri;
fastcgi_param BZ_CACHE_CONTROL 1;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
}
0 new messages