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

Two errors in error_log for conf.d config files #2434

Closed
daBee opened this issue Aug 1, 2022 · 15 comments
Closed

Two errors in error_log for conf.d config files #2434

daBee opened this issue Aug 1, 2022 · 15 comments

Comments

@daBee
Copy link

daBee commented Aug 1, 2022

Issue report

nb: AlmaLinux 8.6

I'm finding this in my error.log:

2022/07/28 14:11:11 [emerg] 3838#0: "passenger_root" directive is duplicate in /etc/nginx/conf.d/passenger.conf:1
2022/07/28 14:11:49 [emerg] 3908#0: a duplicate default server for 0.0.0.0:443 in /etc/nginx/conf.d/project33.conf:8

I don't find any more references to passenger_root anywhere. In fact, my nginx.conf is but a shell, as I'm relying on conf.d to individually bring in my domains.

For the second error, I don't have any other default_server entries in any of my conf files. Passenger does start but the setup throws an ISE hosting 3 domains.

root       11892  0.0  0.0 373968 11328 ?        Ssl  16:57   0:00 Passenger watchdog
root       11895  0.0  0.0 1291500 17052 ?       Sl   16:57   0:00 Passenger core
user3       12129  0.0  0.0 221936  1088 pts/1    S+   17:01   0:00 grep --color=auto Passenger

Are you sure this is a bug in Passenger?

Two errors in Passenger, with the default setup of nginx.

Question 1: What is the problem?
It's not working, throwing errors. I don't know if you can recreate it other than installing it yourself on an AlmaLinux 8.6 box.

Question 2: Passenger version and integration mode:
Passenger processes:

root       11892  0.0  0.0 373968 11328 ?        Ssl  16:57   0:00 Passenger watchdog
root       11895  0.0  0.0 1291500 17052 ?       Sl   16:57   0:00 Passenger core
rich       13909  0.0  0.0 221936  1116 pts/0    S+   17:32   0:00 grep Passenger

passenger status:

Ignoring bigdecimal-1.3.4 because its extensions are not built. Try: gem pristine bigdecimal --version 1.3.4
Ignoring io-console-0.4.6 because its extensions are not built. Try: gem pristine io-console --version 0.4.6
Ignoring json-2.1.0 because its extensions are not built. Try: gem pristine json --version 2.1.0
Ignoring openssl-2.1.2 because its extensions are not built. Try: gem pristine openssl --version 2.1.2
Ignoring psych-3.0.2 because its extensions are not built. Try: gem pristine psych --version 3.0.2
Phusion Passenger(R) Standalone is not running, according to PID file /home/rich/rfs/admin/passenger.3000.pid

nginx.x86_64                                1:1.14.1-9.module_el8.3.0+2165+af250afe.alma       @appstream
nginx-all-modules.noarch                    1:1.14.1-9.module_el8.3.0+2165+af250afe.alma       @appstream
nginx-filesystem.noarch                     1:1.14.1-9.module_el8.3.0+2165+af250afe.alma       @appstream
nginx-mod-http-image-filter.x86_64          1:1.14.1-9.module_el8.3.0+2165+af250afe.alma       @appstream
nginx-mod-http-passenger.x86_64             6.0.14-1.el8                                       @passenger
nginx-mod-http-perl.x86_64                  1:1.14.1-9.module_el8.3.0+2165+af250afe.alma       @appstream
nginx-mod-http-xslt-filter.x86_64           1:1.14.1-9.module_el8.3.0+2165+af250afe.alma       @appstream
nginx-mod-mail.x86_64                       1:1.14.1-9.module_el8.3.0+2165+af250afe.alma       @appstream
nginx-mod-stream.x86_64                     1:1.14.1-9.module_el8.3.0+2165+af250afe.alma       @appstream
nginx-mod-http-passenger.x86_64             6.0.14-1.el8                                       @passenger
passenger.x86_64                            6.0.14-1.el8                                       @passenger

Question 3: OS or Linux distro, platform (including version):

AlmaLinux release 8.6 (Sky Tiger)

Question 4: Passenger installation method:
[X] Phusion YUM repo

Question 5: Your app's programming language (including any version managers) and framework (including versions):

rbenv 1.2.0-14-gc6cc0a1
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux]

Question 6: Are you using a PaaS and/or containerization? If so which one?
None

Question 7: Anything else about your setup that we should know?
None that I know of

@daBee
Copy link
Author

daBee commented Aug 2, 2022

Some nginx/passenger related notes:

worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
include /usr/share/nginx/modules/*.conf;
events {   worker_connections 1024;	}
http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
    access_log		/var/log/nginx/access.log  main;
    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;
    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;
    include /etc/nginx/conf.d/*.conf;
}

server {
  listen                80;
  server_name           project33.ca www.project33.ca;
  return 301            https://$server_name$request_uri;
}
server {
  listen                443 default_server;
  server_name           example1.com www.example1.com;
  access_log            /var/log/nginx/access_project33.log;
  error_log             /var/log/nginx/error_project33.log  warn;
  error_page 404        /404.html;
  client_max_body_size  3M;
  root                  /home/user3/sites/example1;
  include /etc/nginx/default.d/*.conf;
  passenger_enabled     on;
  passenger_ruby        /home/user3/.rbenv/shims/ruby;
  passenger_sticky_sessions on;
  location / {
    autoindex           off;
    sendfile            on;
    sendfile_max_chunk  1m;
  }
  location = /img/favicon.ico { access_log off;}
}

server {
  listen                80;
  server_name           example1.com www.example1.com;
  access_log            /var/log/nginx/access_example1.log;
  error_log             /var/log/nginx/error_example1.log  warn;
  error_page 404        /404.html;
  client_max_body_size  3M;
  root                  /home/user3/sites/example1;
  include /etc/nginx/default.d/*.conf;
  passenger_enabled     on;
  passenger_ruby        /home/user3/.rbenv/shims/ruby;
  passenger_sticky_sessions on;
  location / {
    autoindex           off;
    sendfile            off;
  }
  location = /img/favicon.ico { access_log off;}
}

server {
  listen                80;
  server_name           example2.com www.example2.com;
  access_log            /var/log/nginx/access_example2.log;
  error_log             /var/log/nginx/error_example2.log  warn;
  error_page 404        /404.html;
  client_max_body_size  3M;
  root                  /home/user3/sites/example2;
  include /etc/nginx/default.d/*.conf;
  passenger_enabled     on;
  passenger_ruby        /home/user3/.rbenv/shims/ruby;
  passenger_sticky_sessions on;
  location / {
    autoindex           off;
    sendfile            off;
  }
  location = /img/favicon.ico { access_log off;}
}

passenger_root /usr/share/ruby/vendor_ruby/phusion_passenger/locations.ini;
passenger_ruby ~/.rbenv/shims/ruby;
passenger_instance_registry_dir /var/run/passenger-instreg;

## yum installed:
nginx.x86_64                                1:1.14.1-9.module_el8.3.0+2165+af250afe.alma       @appstream
nginx-all-modules.noarch                    1:1.14.1-9.module_el8.3.0+2165+af250afe.alma       @appstream
nginx-filesystem.noarch                     1:1.14.1-9.module_el8.3.0+2165+af250afe.alma       @appstream
nginx-mod-http-image-filter.x86_64          1:1.14.1-9.module_el8.3.0+2165+af250afe.alma       @appstream
nginx-mod-http-passenger.x86_64             6.0.14-1.el8                                       @passenger
nginx-mod-http-perl.x86_64                  1:1.14.1-9.module_el8.3.0+2165+af250afe.alma       @appstream
nginx-mod-http-xslt-filter.x86_64           1:1.14.1-9.module_el8.3.0+2165+af250afe.alma       @appstream
nginx-mod-mail.x86_64                       1:1.14.1-9.module_el8.3.0+2165+af250afe.alma       @appstream
nginx-mod-stream.x86_64                     1:1.14.1-9.module_el8.3.0+2165+af250afe.alma       @appstream
python3-certbot-nginx.noarch                1.22.0-1.el8                                       @epel

nginx-mod-http-passenger.x86_64             6.0.14-1.el8                                       @passenger
passenger.x86_64                            6.0.14-1.el8                                       @passenger

## nginx -t -c /etc/nginx/nginx.conf:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: [emerg] open() "/run/nginx.pid" failed (13: Permission denied)
nginx: configuration file /etc/nginx/nginx.conf test failed

@daBee daBee changed the title two errors in error_log for conf.d config files Two errors in error_log for conf.d config files Aug 3, 2022
@daBee
Copy link
Author

daBee commented Aug 3, 2022

I'm giving the passenger specific directives some trials tomorrow. Seems the new yum install has me confused. Also, the docs are a bit confusing with regards to commenting out full directives and simply turning off passenger_enabled off in the server perspective, and not by commenting.

@daBee
Copy link
Author

daBee commented Aug 3, 2022

Sent the inclusions for both passenger and my first vhost to the http section. Commented everything else out. On the site conf, I have passenger_enabled on;. Still getting ISEs:

2022/08/03 19:24:34 [alert] 55601#0: *3 Error opening '/home/user3/sites/Passengerfile.json' for reading: Permission denied (errno=13); 
This error means that the Nginx worker process (PID 55601, running as UID 992) does not have permission to access this file. 
Please read this page to learn how to fix this problem: https://www.phusionpassenger.com/library/admin/nginx/troubleshooting/?a=upon-accessing-the-web-app-nginx-reports-a-permission-denied-error; 
Extra info, client: 192.168.1.4, server: domain1.com, request: "GET / HTTP/1.1", host: "server_f.local"

That Passengerfile.json doesn't even exist.

Anybody home here?

@CamJN
Copy link
Contributor

CamJN commented Aug 6, 2022

Is your app code at the path /home/user3/sites/ or in the subdirs /home/user3/sites/example2, /home/user3/sites/example1? The nginx root directive should point to the static files for your app, and if the app code is not one directory above the static files, then you should use the passenger_app_root directive to point to the code dir: https://www.phusionpassenger.com/docs/references/config_reference/nginx/#passenger_app_root. Let me know if this helps.

@daBee
Copy link
Author

daBee commented Aug 6, 2022

/home/user3/sites/vhost1 I changed to /home/user3/sites/vhost1/public and restarted nginx. Same issue:

2022/08/06 13:21:26 [alert] 51796#0: *12 Error opening '/home/user3/sites/vp/Passengerfile.json' for reading: Permission denied (errno=13); This error means that the Nginx worker process (PID 51796, running as UID 992) does not have permission to access this file. Please read this page to learn how to fix this problem: https://www.phusionpassenger.com/library/admin/nginx/troubleshooting/?a=upon-accessing-the-web-app-nginx-reports-a-permission-denied-error; Extra info, client: 192.168.1.4, server: domain2.com, request: "GET /favicon.ico HTTP/1.1", host: "www.domain2.com", referrer: "http://www.domain2.com/"

Still no Passengerfile.json file in there. Just tried another vhost and the error is that it's looking for /home/user3/sites/Passengerfile.json, not one each for specific vhosts.

Just tried passenger_app_root and now it gives me the expected error:

2022/08/06 18:25:35 [alert] 53159#0: *34 Error opening '/home/user3/sites/vhost1/Passengerfile.json' for reading: Permission denied (errno=13); This error means that the Nginx worker process (PID 53159, running as UID 992) does not have permission to access this file. Please read this page to learn how to fix this problem: https://www.phusionpassenger.com/library/admin/nginx/troubleshooting/?a=upon-accessing-the-web-app-nginx-reports-a-permission-denied-error; Extra info, client: 192.168.1.4, server: vhost1.com, request: "GET /favicon.ico HTTP/1.1", host: "www.vhost1.com", referrer: "http://www.vhost1.com/"

No such file as well.

@daBee
Copy link
Author

daBee commented Aug 7, 2022

Tried your new directive, and it still couldn't find the specific vhost json file either. None of them have showed up after nginx restart.

@CamJN
Copy link
Contributor

CamJN commented Aug 8, 2022

Does id -nu 992 give the user you expect?

@daBee
Copy link
Author

daBee commented Aug 8, 2022

nginx. I've added my user to that group for nginx log reasons. The usual confusion over all that. Also, nginx is confusing, starting out as root, then moving to its own user. I'm not sure what user to expect.

Should I stop using the conf.d option and go back to the old directives? This is supposed to replicate the CentOS way, which didn't use this. For some reason this new structure isn't working. I'm not sure why there's two ways.

@daBee
Copy link
Author

daBee commented Aug 8, 2022

I just set the root directory for a test site back to the default /usr/share/nginx/html location, and nginx came back, but still with that error for passenger:

2022/08/08 12:49:38 [alert] 56326#0: *45 Error opening '/home/user3/sites/vhost1/Passengerfile.json' for reading: Permission denied (errno=13); This error means that the Nginx worker process (PID 56326, running as UID 992) does not have permission to access this file. Please read this page to learn how to fix this problem: https://www.phusionpassenger.com/library/admin/nginx/troubleshooting/?a=upon-accessing-the-web-app-nginx-reports-a-permission-denied-error; Extra info, client: 192.168.1.4, server: vhost1.com, request: "GET /favicon.ico HTTP/1.1", host: "www.vhost1.com", referrer: "http://www.vhost1.com/"

drwxr-xr-x. 2 root root 99 Jun 15 18:30 html

Went back to ~/sites: drwxr-xr-x. 9 user3 user3 4.0K Mar 12 2020 vhost1/ making sure read and execute were possible, and restarted. Same issue. So I get farther in a non-custom www path. I just wish I could use this convenient path, as it's explained is perfectly fine.

@daBee
Copy link
Author

daBee commented Aug 8, 2022

@CamJN Has this been tested on AlmaLinux 8.6?

@daBee
Copy link
Author

daBee commented Aug 8, 2022

Hi Camden. Can we get this completed, please? I don't know what to try next.

@CamJN
Copy link
Contributor

CamJN commented Aug 15, 2022

I just created a clean almalinux 8.6 vm, and with the following steps, I installed and ran a rails app using rbenv and ruby 3.1.2. The initial user is root so i don't have to sudo everything.

yum install -y yum-utils curl git gcc bzip2 openssl-devel libyaml libffi-devel readline-devel zlib-devel gdbm-devel ncurses-devel make procps
yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-$(< /etc/redhat-release tr -dc '0-9.'|cut -d \. -f1).noarch.rpm
yum-config-manager --enable epel
curl --fail -sSLo /etc/yum.repos.d/passenger.repo https://oss-binaries.phusionpassenger.com/yum/definitions/el-passenger.repo
yum install -y nginx-mod-http-passenger libsqlite3x-devel openssl3-devel openssl3-libs openssl3

su -s /bin/bash nginx
curl -fsSL https://github.com/rbenv/rbenv-installer/raw/HEAD/bin/rbenv-installer | bash
PATH=$PATH:~/.rbenv/bin
eval "$(rbenv init - bash)"
RUBY_CONFIGURE_OPTS=--with-openssl-dir=/usr/include/openssl3 rbenv install 3.1.2
rbenv global 3.1.2
gem install rails --no-document
cd ~
rails new blog --skip-javascript
cd ~/blog/
sed -e /puma/d -i Gemfile
bundle install
sed -e 's/articles/application/' -e 's/# root/root/' -i ~nginx/blog/config/routes.rb
sed -e '/Base/a def index\nend' -i ~nginx/blog/app/controllers/application_controller.rb
exit
ln -sf ~nginx/blog /srv/blog

sed -e '/root.*$/a passenger_enabled on;'  -e 's@root.*;$@root /srv/blog/public;@' -i /etc/nginx/nginx.conf
sed -e 's@passenger_ruby.*@passenger_ruby /var/lib/nginx/.rbenv/shims/ruby;@' -i /etc/nginx/conf.d/passenger.conf
nginx
curl -I http://localhost/

@daBee
Copy link
Author

daBee commented Aug 15, 2022

I'm not clear on your links, but here's what I've tried. I still get 403 Forbidden issues and errors that it can't find my favicon.ico, which suggests Passenger is not loading properly, pointing to my site/public directory.

I'm using Sinatra. Site structure is copied from some time ago, and nothing has changed. It's in /home/myuser/sites/site1. I've tried all owners/groups, full permissions (yes I know, but I want to work back from a working/functioning environment), I've tried new users and allowing nginx to be part of that group. That's where I am now. Always 403 errors. nginx -t shows fine, as does a restart of nginx. I get these on a curl -I localhost and using a browser on the LAN.

$ namei -om /home/user3/sites/vhost1
f: /home/user3/sites/vhost1
 dr-xr-xr-x root   root   /
 drwxr-xr-x root   root   home
 drwx--x--x user3   user3   user3
 drwxr-x--- newuser newuser sites
                          vhost1 - No such file or directory

Not sure why it's not seeing that subsirectory.

@CamJN
Copy link
Contributor

CamJN commented Aug 16, 2022

I assume you're just trying to label things for my understanding but in case it's a typo, you mention /home/myuser/sites/site1 and cannot find /home/user3/sites/vhost1 which is a different path.

@daBee
Copy link
Author

daBee commented Aug 16, 2022

Yes, they are the same. I've gotten to the point that passenger is telling me there's a ruby version error. But I can't get into root and load ~/.bash_profile to load. I'm on the AlmaLinux forum asking what's going on with version 8.6 as it's misbehaving.

@daBee daBee closed this as completed May 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants