Environment:
Digital Ocean Ubuntu 18.04 droplet, nginx installed, application in Ruby
on Rails, Using capistrano for deployment. (It uses a user called deploy)
Everything was working fine earlier.
I got message on Digital Ocean, and then I upgraded a few packages on Digital Ocean Ubuntu 18.04 LTS server. Since then, the site has been broken and I get 403 errors.
Using $nginx -V, I verified that the version got upgraded from 1.12.2
to 1.18.0
$sudo tail /var/log/nginx/error.log Following error is shown.
2021/01/11 21:58:55 [error] 5678#5678: *1 directory index of
"/home/deploy/my_app/current/public/" is forbidden, client:
999.888.255.141, server: *.myserver.com, request: "GET / HTTP/2.0", host: "hmm.myserver.com"
/etc/nginx/sites-available/default file:
server {
listen 80;
listen [::]:80;
server_name *.myserver.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
server_name *.myserver.com;
passenger_enabled on;
rails_env production;
root /home/deploy/my_app/current/public;
ssl_certificate /home/deploy/letsencrypt/fullchain.pem;
ssl_certificate_key /home/deploy/letsencrypt/privkey.pem;
# redirect server error pages to the static page /50x.html
}
$ sudo view nginx.conf file:
user www-data;
worker_processes auto;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Phusion Passenger config
##
# Uncomment it if you installed passenger or passenger-enterprise
##
# include /etc/nginx/passenger.conf;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}
$ which ruby
/home/deploy/.rbenv/shims/ruby
$ sudo passenger-memory-stats
This shows as:
Version: 6.0.7
Date : 2021-01-11 23:58:57 +0000
------------- Apache processes -------------
*** WARNING: The Apache executable cannot be found.
Please set the APXS2 environment variable to your 'apxs2' executable's filename, or set the HTTPD environment variable to your 'httpd' or 'apache2' executable's filename.
--------- Nginx processes ----------
PID PPID VMSize Private Name
------------------------------------
6884 1 175.0 MB 0.7 MB nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
6885 6884 175.2 MB 0.8 MB nginx: worker process
### Processes: 2
### Total private dirty RSS: 1.47 MB
--- Passenger processes ---
### Processes: 0
### Total private dirty RSS: 0.00 MB
$ ps aux | grep nginx shows as:
root 6884 0.0 0.1 179176 5712 ? Ss Jan11 0:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
www-data 6885 0.0 0.3 179436 11352 ? S Jan11 0:00 nginx: worker process
deploy 8438 0.0 0.0 12940 1012 pts/0 S+ 00:24 0:00 grep --color=auto nginx
$ ps aux | grep passenger shows as:
deploy 8478 0.0 0.0 12940 936 pts/0 S+ 00:29 0:00 grep --color=auto passenger
I have restarted nginx several times. I have also tried reinstalling the Rails application.
I found this link. See section "Permission denied".
But on my server, there is no file /Users/phusion/Sites/rack.test
. In fact, the server does not even have /Users or /Users/phusion folders at all.
I am a newbie.
Any help to resolve this 403 error is greatly appreciated.
2
Answers
The problem is resolved.
In file nginx.conf the following line needed uncommenting.
include /etc/nginx/passenger.conf;
Few suggestions.
You can check the path of your passenger installation with
then compare with the one referenced in nginx.conf.
Also,
Confirm that you have the right permissions and ownership on
/home/deploy/my_app/current/public/