summary of issue: after compiling nginx/dynamic passenger module by hand, I can't tell if passenger is starting up or what the problem is serving my application, but no matter what page I try I get 403 forbidden or 404 not found.
details: I had a working rails app under the passenger+nginx bundle but due to security alert on nginx 1.18 and my company's security policy, I had to clear out my nginx setup and start over, manually compiling everything according to this link. After a half day of struggling, nginx will start however when i try to access my site via browser, I get this in the error log:
2022/02/24 00:03:06 [error] 156967#156967: *3 directory index of "/home/<app name>/staging/current/public/" is forbidden, client: <client ip addr>, server: <server ip addr>, request: "GET / HTTP/1.1", host: "<server ip addr>"
What I think is happening is that passenger is starting but is having some error when it tries to run the rails app. But I can't be sure since
- the error message is completely uninformative and I suppose that if passenger were not starting, nginx would fail with a similar message.
- i can't run
passenger-status
, I get an error as per this question that passenger can't find its instance registry folder. Setting the appropriate env. variablePASSENGER_INSTANCE_REGISTRY_DIR
to /tmp didn't fix this for me even though I do see passenger files are created there.
I have these settings in my nginx.conf:
load_module modules/ngx_http_passenger_module.so
http {
:
passenger_root /home/<app name>/.rvm/gems/ruby-2.6.5/gems/passenger-6.0.12
passenger_ruby /home/<app name>/.rvm/gems/ruby-2.6.5/wrappers/ruby
:
I have these settings in sites-enabled/default:
root /home/<app name>/staging/current/public;
passenger_enabled on;
passenger_app_env staging;
And I am able to run passenger standalone by going to the rails apps directory and running RAILS_ENV=staging passenger start
. No apparent problems starting the app. Nor with the rails server
.
How can I diagnose what's going on? How can I know if passenger is even the source of the error log entry? I am totally stuck after 2 days of trying everything I can find in SO.
thanks in advance for any help.
edits
After my initial question, I noticed that sudo service nginx status
was complaining that Passenger was not correctly installed/compiled. However, I cleared out everything (nginx, passenger) and set it up again from scratch, and I am back to the above problems, but there is NO error about passenger when I now check the status.
I also became convinced Passenger is not being called at all because if I put a "hello, world" in index.html in my app's public directory, it gets served by Nginx. Nor do I see Passenger processes when I check passenger=memory-stats
. So I think Passenger is not starting up.