Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not spawn process for application, wrong root path when using replacement patterns #2245

Open
roman-sitewits opened this issue Jan 21, 2020 · 1 comment

Comments

@roman-sitewits
Copy link

roman-sitewits commented Jan 21, 2020

I found a curious bug, couldn't find it on here or stackoverflow. It could be due to using replacement patterns to set the root or due to hosting from home folder (snap packages including Chromium had access issues in home folder including failing to save to ~/Downloads). I'm using nginx with per-domain tenants in a sibling folder without issues, so it doesn't look like it's nginx's issue. Sorry, it's a bit elaborate.

The error looks like this (nothing special here until you see the actual resolved paths below):
...age/Cor/App/Implementation.cpp:221 ]: Could not spawn process for application /home/user/.WORK/app: An operating system error occurred while preparing to spawn an application process: Cannot lstat("/home/user/.WORK/app/index.js"): No such file or directory (errno=2)

Where the path was actually resolved by nginx as /home/user/.WORK/app/newapp/index.js so /newapp/ got skipped, I blamed the empty replacement $1 at first, but no, it's just skipped.

The nginx settings look like the following:

server {
	listen 80;
	server_name   ~^([^.]*)\.app$;

	# $apps path hosts all kinds of apps under it
	# resolving to site name in sub folder
	set $apps "/home/user/.WORK/app";
	set $app_root "$apps/$1";

	root "$app_root";

	passenger_enabled on;
	passenger_app_type node;
	passenger_startup_file index.js;
}

The expected results are:
http://newapp.app
now root directive above should resolve to /home/user/.WORK/app/newapp/index.js

this doesn't work, resolves to /home/user/.WORK/app/newapp correctly,
but understood as /home/user/.WORK/app/index.js
set $apps "/home/user/.WORK/app/$1";
but adding it the second time works???
set $app_root "$apps/$1";

then, it was evident that whatever folder I add, the last item was always ignored (even if it exists)
this is equivalent to the last one and produces /home/user/.WORK/app/newapp/newapp
set $apps "/home/user/.WORK/app";
set $app_root "$apps/$1/$1";

but the issue was that the error would always say
cannot stat /home/user/.WORK/app/newapp/abc/index.js
ignoring the last /def/ part once again (no matter if end slashes are used or not)
set $app_root "$apps/$1/abc/def/";

so simply adding garbage "fixes" the parser
set $app_root "$apps/$1/sdgfrkjth/";

Once again, the paths are replaced correctly
so $apps/$1/b8huj5h6/
is replaced to become /home/user/.WORK/app/newapp/b8huj5h6/ correctly,
but the parser thinks it need to use /home/user/.WORK/app/newapp/index.js ignoring the last part

Using:
Passenger 6.0.4 as nginx-module on Ubuntu 18 (mint)
via Phusion APT repo
it's a basic Node.js app

@pauljohn32
Copy link

I see similar problem with Passenger Enterprise. Is it same problem? I made a report about it. #2251

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants