Still seeing welcome to ngnix after setup - ruby-on-rails

I have set up and deployed an application using Capistrano and set up the server and ngnix config file, however, I'm still seeing the Welcome to ngnix welcome screen.
Here is what I have in the /etc/nginx/sites-enabled/default file
server {
listen 80;
listen [::]:80 ipv6only=on;
server_name IP;
passenger_enabled on;
rails_env production;
root /home/poladmin/poetry-out-loud-v2/current/public/;
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
But as I said when I go to the server IP all I see is

Since you edited /etc/nginx/sites-enabled/default file, try to reload nginx with nginx -s reload command (if you are using Linux, or similar depending on your operating system and nginx version).

As you have edited the nginx config file you can try to restart nginx by doing sudo /etc/init.d/nginx restartto make the config file take effort. Also do not forget to start the real ruby server and make sure it is listening to the same port you configured through nginx.(some times the ruby app may be running on a different port)

Related

Ngnix still seeing welcome screen after configuration

I have set up and deployed an application using Capistrano, Nginx, Passenger and set up the server and ngnix config file, however, I'm still seeing the Welcome to ngnix welcome screen.
Here is what I have in the /etc/nginx/sites-enabled/default file
server {
listen 80;
listen [::]:80 ipv6only=on;
server_name IP;
passenger_enabled on;
rails_env production;
root /home/poladmin/poetry-out-loud-v2/current/public/;
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
I have restarted Ngnix but I'm still not seeing the website.
Sounds like Nginx is serving you the content from it's installation directory. It's usually /usr/share/nginx but you can confirm by running:
nginx -V 2>&1 | tr ' ' '\n' | grep prefix
This will happen if it can't find a more suitable server from your configuration. Here's a few observations:
server_name IP;
This directive tells Nginx which host names to match in client requests in order to pass the request to this server. So requests to http://ip will be handled here, is that your intention?
Is your root directory really within someone's home directory structure? Fair enough...
You can lose the trailing slash from that directive, to make it:
root /home/poladmin/poetry-out-loud-v2/current/public;
but, but, what about the slash?
It lives in here:
location / {
blah blah blah...
}
You currently have no location directives apart from location = /50x.html which contains = so is an exact match only. A request for any other URL doesn't have a matching location within this server block.
try it with the folowing commands
first: service nginx configtest
to verify the Nginx functioning
second: service nginx restart

Application not loading in Ubuntu 18.04, NGINX, Passenger configuration

I have installed NGINX and Passenger on Ubuntu 18.04 and am having issues getting any meaningful indication of what's wrong with my configuration.
/etc/nginx/nginx.conf
http {
# pretty much the default configuration except for this...
passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;
include /etc/nginx/sites-enabled/*;
}
/etc/nginx/sites-enabled/my_app (this is a symlink to sites-available)
server {
listen 80;
server_name my.app.ip.address;
root /path/to/public/folder;
passenger_enabled on;
passenger_app_root /path/to/app/root; # not public folder
passenger_ruby /home/appuser/.rvm/gems/ruby-2.0.0-p648/wrappers/ruby;
rails_env staging;
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
Results of systemctl status nginx
Results of passenger-status
Output of /var/log/nginx/error.log
When I try to access the IP address via a web browser, it refuses to connect and suggests I check the connection and firewall. Any thoughts on what the issue could be?
You need to remove passenger_app_root. That directive is for where passenger is, not the root of your app.
If you're using the standard RoR layout where public is a subfolder of the application root, you don't need to specify anything, but if they really are completely different than the directive you're looking for is passenger_root, which configures the root of your application.

Deployed Rails app still seeing nginx splash page

I've just set up my first Digital Ocean VPS and managed to deploy my Rails app by following this guide: https://gorails.com/deploy/ubuntu/14.04
Unfortunatley I am still seeing the nginx splash page and hoep you guys can help me fix this?
In the nginx error log I am seeing this:
[ 2016-04-20 14:48:15.4541 31875/7f70762f57c0 age/Ust/UstRouterMain.cpp:342 ]: Passenger UstRouter online, PID 31875
2016/04/21 14:58:58 [emerg] 1721#0: "listen" directive is not allowed here in /etc/nginx/sites-enabled/default.save:27
My nginx conf looks like:
server {
listen 80 default_server;
server_name dev.myapp.co.uk;
passenger_enabled on;
rails_env production;
root /home/deploy/myapp/current/public;
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
I obviously have changed "myapp" to my correct domain and app name as appropriate.
Any ideas?
The issue seems like you are having two nginx configuration files inside /etc/nginx/sites-enabled/ and both of them have the same listen 80 default_server; line.

cannot assess rails app on amazon ec2

I'm using Amazon EC2 and tried to deploy a rails project.
I have install nginx/passenger and successfully made nginx server run.
I started my rails project with name "forfun"
then I set the root of nginx to /home/ubuntu/rails/forfun/public
I initialized a file named "index.html", then I could see the page in browser
(http://[my ip]:80)
However, what i really wanna see is the welcome page of rails app.
I tried do remove index.html and see what i got. I saw 404 Forbidden error.
/var/log/nginx/error.log reveals that directory index of "/home/ubuntu/rails/forfun/public/" is forbidden
What step i actually missed?
by the way, do i need to do "rails server" while nginx is running?
ps:
(1) /opt/nginx/conf/nginx.conf
http {
passenger_root /usr/local/rvm/gems/ruby-2.3.0/gems/passenger-5.0.26;
passenger_ruby /usr/local/rvm/gems/ruby-2.3.0/wrappers/ruby;
...
server {
listen 80;
server_name 52.196.XX.XXX;#my amazon public ip
root /home/ubuntu/rails/forfuni/public;
}
(2)/etc/nginx/sites-enabled/default
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /home/ubuntu/rails/forfun/public;
index index.html index.htm;
}
Try adding /etc/nginx/sites-enabled/default
server {
listen 80 default_server;
server_name 52.196.XX.XXX;#my amazon public ip;
passenger_enabled on;
passenger_app_env development; #or whatever rails env you want.
The whole process of deploying a rails app using nginx/passenger is documented here. See the nginx section.
https://www.digitalocean.com/community/tutorials/how-to-deploy-a-rails-app-with-passenger-and-nginx-on-ubuntu-14-04

Issue with Nginx redirecting to Rails app

So, I have a domain: coolapp.com Now I want to make it so I can have two subdomains, such as game.coolapp.com and sports.coolapp.com. I have two server configurations in the nginx config as follows:
server {
listen 80;
server_name sports.coolapp.com;
location / {
root /home/deployer/Sports/current/public;
index index.php;
}
passenger_enabled on;
}
server {
listen 80;
server_name game.coolapp.com;
location / {
root /home/deployer/Game/current/public;
index index.php;
}
passenger_enabled on;
}
For some reason, both of these domains are redirecting to the 'sports' app. They SHOULD each by redirecting to their own application, but are interfering with each other.
I am running the Sports app via passenger, with something like 'passenger start --port 80', and I'm running the second app with 'passenger start --port 81'. Should I be running these with different arguments, or what exactly is causing the issue here?
Your problem is not quite clear to me. I am making the following assumptions in my answer.
You are running 3 apps all on Phusion with Nginx.
Nginx configuration is pretty straight forward. Probably you have configured nginx.conf properly because you main app is working.
The next thing you should do is read the phusion passenger doc on how to run Rails on subdomain. Reading https://www.phusionpassenger.com/documentation/Users%20guide%20Nginx.html#deploying_a_rack_app will give you a lot of insight. I recommend you read the entire doc.
I think there is a problem in the way you have configured your nginx.conf and how you are starting you phusion passenger (BTW I think you do not even have to start the phusion passenger explicitly and that NGINX should take care of that)
In your nginx configuration you are listening to port 80 and in your phusion passenger command you are asking it to listen to port 81 and 82. Change you nginx configuration to read like (BTW it is better to use sites-available & site-enabled for this)
server {
listen 80;
server_name sports.coolapp.com;
root /home/deployer/Sports/current/public;
passenger_enabled on;
}
server {
listen 80;
server_name games.coolapp.com;
root /home/deployer/Sports/current/public;
passenger_enabled on;
}
I hope you have configured your subdomains properly. You should double check that as well.
Save changes. Restart Nginx and you should be good to go.

Resources