Saturday, May 5, 2018

ubuntu - Nginx 404 Deploying Ruby on Rails Application with Phusion Passenger



There are a lot of moving parts here that I have varying levels of familiarity with, so I'm hoping another set of eyes will help me discover why I'm getting a 404 after deploying my Rails app on Nginx running Phusion Passenger.



My app's /public directory currently resides at:



$pwd
>> /root/public_html/photobook/public



My server settings in nginx.conf:



server {
listen 80;
server_name pb.mysite.com;
root /root/public_html/photobook/public; # <--- be sure to point to 'public'!
passenger_enabled on;
}



But after restarting nginx:



sudo /opt/nginx/sbin/nginx


Going to my browser displays a 404 page served up by Nginx.



Are there rules for handling subdomains differently than I'm not aware of? Or is this something else entirely?




Also, since I'm new to Passenger on Nginx, is there a log file I should find that might give me more helpful feedback on the 404, like what page it's looking up?



Thanks!



Edit



First, thanks for the advice on /var/log.



I didn't know about it; this will be a great help in the future.




I'm not sure my syslogs (I have two that appear current and then it looks like .gz backups going back) are recording anything relevant, however:



Jun 23 01:25:01 myusername /USR/SBIN/CRON[11379]: 
(root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Jun 23 01:49:01 myusername -- MARK --


Just that, the hourly cron task and whatever -- MARK -- is for, all the way back. Any ideas?


Answer




Check under /var/log. Unless you have an nginx or passenger log, everything will be under syslog.



Your next step will depend on what you see there. If the solution isn't readily apparent, post your log as nginx starts cold so we can get a better clue as to where to go next.



EDIT:



Since you have nginx under /opt, take a look under /opt/nginx/logs/error.log.



Also, you'll want to take your app out of /root as it can cause nginx to mis-read the path if you run nginx as root.




Lastly, consider creating an nginx user to run nginx to limit your exposure to baddies.


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...