I am already deployed my Rails app with Passenger and Nginx and it's working fine.
Below is my servier configuration:
server {
listen 80;
server_name localhost;
location / {
root /var/www/demo/public;
passenger_enabled on;
rails_env production;
}
Now I want to deploy a second app to a sub URI. Here the documentation is a little unclear.
Could anyone please suggest me what will be the next configuration?
Below is the configuration I am using for my second (Sinatra) application:
location /log {
root /var/www/logger/public;
passenger_base_uri /log;
passenger_enabled on;
}
I am getting "404 Not Found". Please suggest what I am missing here.
Finally it's working!
nginx.conf:
server {
listen 80;
server_name localhost;
location / {
root /var/www/demo/public;
passenger_enabled on;
rails_env production;
}
location /test {
root /var/www/demo;
passenger_base_uri /test;
passenger_enabled on;
}
Then:
ln -s /var/www/logger/public /var/www/demo/test
Thanks for all your help.
Add ^~ before the sub-directory:
location /log
To:
location ^~ /log
Related
I'm trying to setup my rails server and passenger wont recognize my app giving this error on log:
[error] 1473#1473: *1 "/home/myapp/public/index.html" is not found (2: No such file or directory)
or a 404 error in client.
i've done all troubleshooting possiilities to resolve but nothing.
here is my server block:
server {
listen 80;
server_name mydomaiin.com;
rails_env development;
# Turn on Passenger
passenger_enabled on;
passenger_ruby /home/myapp/.rbenv/versions/2.4.0/bin/ruby;
# Tell Nginx and Passenger where your app's 'public' directory is
root /home/myapp/public;
}
can anyone help me?
thanks
As your root dir is in /home/myapp/myapp, update your server conf:
server {
listen 80;
server_name mydomaiin.com;
rails_env development;
# Turn on Passenger
passenger_enabled on;
passenger_ruby /home/myapp/.rbenv/versions/2.4.0/bin/ruby;
# Tell Nginx and Passenger where your app's 'public' directory is
root /home/myapp/myapp/public;
}
I have my Phusion Passenger Nginx configured to as below :
server {
listen 80;
server_name blog.abc.com;
passenger_enabled on;
root /app/public;
}
Im about to host the main site abc.com also in this machine. How can I do that (Its a separate app)? Is it possible to add another server block like this :
server {
listen 80;
server_name abc.com;
passenger_enabled on;
root /app2/public;
}
Phusion Passenger author here. Yes. Just add another virtual host block for the other app. It works exactly as expected.
I configured my second app on sub-uri of first app. Below is the nginx conf and settings what i done.
nginx.conf:
server {
listen 80;
server_name localhost;
location / {
root /var/www/demo/public;
passenger_enabled on;
rails_env production;
}
location /test {
root /var/www/demo;
passenger_base_uri /test;
passenger_enabled on;
}
Then add symbolic link:
ln -s /var/www/logger/public /var/www/demo/test
Been trying to search for a time but can't seem to find a solution. I want to set multiple apps in one server via nginx. Current nginx.conf is as follows:
server {
listen 80;
server_name mydomain.co;
root /mydomain/current/public;
passenger_enabled on;
rails_env production;
}
server {
listen 80;
server_name testing.mydomain.co;
root /mydomain-test/current/public;
passenger_enabled on;
rails_env test;
}
It serves up the correct environment (test) but doesn't serve the correct codebase. I checked the directory mydomain-test via ssh and it contains the recent code but is not being served by nginx.
Basically, what I want is:
mydomain.co to serve /mydomain/current/public
testing.mydomain.co to serve /mydomain/current/public
How is this done correctly?
I believe the root directive should be in the location section. I am unsure of the rails directive and passenger_enabled directive but the rest is similar to what I use and works. Might be best to also specify the index script (i have it set to index.php but change as appropriate).
Once you have made the changes be sure to restart nginx.
server {
listen 80;
server_name mydomain.co;
location / {
root /mydomain/current/public;
index index.php;
}
passenger_enabled on;
rails_env production;
}
server {
listen 80;
server_name testing.mydomain.co;
location / {
root /mydomain-test/current/public;
index index.php;
}
passenger_enabled on;
rails_env test;
}
I have two Ruby applications, one is under Rails and the another is under Sinatra.
How can I deploy both these apps in Nginx and Passenger with one in the root ("localhost:3000") and the other in subroot ("localhost:3000/test")?
The Rails application is running with this configuration. Everything seems to work OK:
server {
listen 80;
server_name localhost;
location / {
root /var/www/demo/public;
passenger_enabled on;
rails_env production;
}
location /test/ {
root /var/www/test/public;
passenger_base_uri /test/;
proxy_pass http://10.0.3.12:80/test/;
passenger_enabled on;
}
I am not able to access the second application.
The server returns 404 for the second app and the first app is still running.
I believe you need to define local servers, that only listen on local port and define your passenger apps there. Your actual server listening on port should only act as proxy.
server {
listen localhost:8181;
server_name test_app;
root /var/www/test/public;
passenger_enabled on;
}
server {
listen localhost:8182;
server_name demo_app;
root /var/www/demo/public;
passenger_enabled on;
rails_env production;
}
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://localhost:8182/;
}
location /test/ {
proxy_pass http://localhost:8181/;
}
}
I didn't have chance to test this config, so it might have some minor flaws, but it should be correct in high-level terms.
In nginx.conf:
server {
listen 80;
server_name localhost;
location / {
root /var/www/new/public;
passenger_enabled on;
rails_env production;
}
location /test {
root /var/www/demo;
passenger_base_uri /test;
passenger_enabled on;
}
Add a soft link:
ln -s /var/www/loggerapp/public /var/www/new/test
I have simple application which works well on Apache but gives me error 403 after moving to Nginx.
Here is my configuration:
server {
server_name myapp.com;
access_log off;
root /home/www/myapp/public;
autoindex on;
passenger_enabled on;
rails_env production;
}
Nginx is running from www-data user which has r+x permissions to all the folders on the path to the application.
Nginx is 0.8.54 and Passenver is 3.0.5.
Any ideas what can be wrong?
Obviously no reasonable errors in nginx log file (I increased logging level to maximum) and also nothing in rails log files.
You're missing the http port:
server {
listen 80;
...
}