I have:
Ubuntu 12.04 LTS
ruby-1.9.3-p194
Rails 3.2.7
I am trying to get access to my Rails application through Nginx + Passenger.
/opt/nginx/conf/nginx.conf file is:
user test;
worker_processes 1;
events {
worker_connections 1024;
}
http {
passenger_root /home/test/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.14;
passenger_ruby /home/test/.rvm/wrappers/ruby-1.9.3-p194/ruby;
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name 10.11.11.178;
root /efiling/public;
passenger_enabled on;
location / {
root html;
index index.html index.htm;
}
....
When I enter a link 10.11.11.178 I get Welcome to nginx!
But I am expecting to get Rails app default page.
What is wrong?
Thanks in advance.
#Jashwant. First, I removed line as was mentioned by #Brandon. Second, I removed index.html file from my_app\public folder.
Try removing the following from the config:
location / {
root html;
index index.html index.htm;
}
Related
When uploading static files to my server using Nginx as the web server my css, javascript, and google fonts are not working as they do when testing the site on localhost.
I'm running Nginx in a docker container using the base image.
Dockerfile
FROM nginx
COPY example.com.conf /etc/nginx/nginx.conf
COPY build /etc/nginx/html/
nginx.conf
user nginx;
events {
worker_connections 4096; ## Default: 1024
}
http {
server {
listen 80;
listen [::]:80;
server_name example.com;
include /etc/nginx/mime.types;
root /etc/nginx/html;
index index.html;
location ~ \.css {
add_header Content-Type text/css;
}
location ~ \.js {
add_header Content-Type application/x-javascript;
}
location / {
try_files $uri /index.html =404;
}
}
}
Can someone tell me whats wrong with my conf?
Also when viewed on Chrome the console logs this Resource interpreted as Stylesheet but transferred with MIME type text/plain
Some other SO post I looked at:
SO post
SO post
With the help of this SO answer and the comments I was able to get it working. If my answer doesn't help you I suggest you look at that one when running Nginx in a docker container.
For me it was moving the include /etc/nginx/mime.types; and adding sendfile on;
outside my server block and in the http block
My example.com.conf now looks like this:
user nginx;
events {
worker_connections 4096; ## Default: 1024
}
http {
include /etc/nginx/mime.types;
sendfile on;
server {
listen 80;
listen [::]:80;
server_name example.com;
root /etc/nginx/html;
index index.html;
location ~ \.css {
add_header Content-Type text/css;
}
location ~ \.js {
add_header Content-Type application/x-javascript;
}
location / {
try_files $uri /index.html =404;
}
}
}
There are two questions:
How to deploy a part of the RAILS API application on the nginx server (via Windows), at the moment I have deployed only the client part written in Angular, now I need to display the data from the server side written in Rails.
my nginx.conf file is bellow
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root html/dist;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html/dist;
}
}
}
After updating the page, if the link is specified in about this format http://localhost/login, it will return an error 404 although it worked before updating. How can this be remedied?
On a EC2 with ubuntu 14.04 with nginx/passenger/rails came with this log on nginx:
App 31063 stderr: * ERROR *: Cannot execute /usr/local/lib/ruby:
Permission denied (13)
App 31065 stderr: /etc/profile.d/rbenv.sh: line 3: rbenv: command not
found nginx conf is:
worker_processes 1;
error_log logs/error.log;
events {
worker_connections 1024;
}
http {
passenger_root /usr/local/lib/ruby/gems/2.2.0/gems/passenger-5.0.18;
passenger_ruby /usr/local/lib/ruby;
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name teste.com;
root /home/ubuntu/teste/current/public;
passenger_enabled on;
rails_env production;
access_log logs/access.log;
location ~ ^/(assets)/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
}
someone cloud give some light? thank's
Execute in Terminal
sudo chmod o+x "/root"
Resolve this problem!
* ERROR *: Cannot execute /root/.rbenv/versions/2.2.3/bin/ruby Phusion Passenger Permission denied (13)
Phusion Passenger nginx centos
http://oki2a24.com/2014/02/08/try-to-install-ruby-and-redmine/
passenger_ruby should point to the ruby command itself. Yours appears to point to a directory /usr/local/lib/ruby/ (based partly on the passenger_root path).
https://www.phusionpassenger.com/library/config/nginx/reference/#passenger_ruby
Try changing passenger_ruby to /usr/bin/ruby , or whatever your path is. "which ruby" would give you the path, if it's in your PATH environment variable.
I have an issue with my rails application running with passenger and nginx hosted in Ubuntu 12.04.
In the nginx.conf file below, my "example.com" (Regular HTML) and "redmine.example.com" (Rails app) are working perfectly, but my "crete.example.com" (Another Rails app) is showing "502 bad gateway". I have them both hosted in /var/data with the same permissions and ownerships, also tried different ports, I can't think of something else to try.
worker_processes 1;
events {
worker_connections 1024;
}
http {
passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server{
listen 80;
server_name example.com;
root /opt/nginx/html;
}
server{
server_name redmine.example.com;
root /var/data/redmine/public;
passenger_enabled on;
location ~ ^/<SUBURI>(/.*|$){
alias /var/data/redmine/public$1;
passenger_base_uri /redmine;
passenger_app_root /var/data/redmine;
passenger_document_root /var/data/redmine/public;
passenger_enabled on;}
}
server{
server_name crete.example.com;
root /var/data/crete/public;
passenger_enabled on;
location ~ ^/<SUBURI>(/.*|$){
alias /var/data/crete/public$1;
passenger_base_uri /crete;
passenger_app_root /var/data/crete;
passenger_document_root /var/data/crete/public;
passenger_enabled on;}
}
}
This are my Ruby and Rails versions:
ruby 2.0.0p451 (2014-02-24 revision 45167) [x86_64-linux]
Rails 4.1.0
My nginx error.log
2014/05/02 12:29:50 [error] 3343#0: *4 upstream prematurely closed connection while reading response header from upstream, client: xxx.xx.xx.xx, server: crete.example.com, request: "GET / HTTP/1.1", upstream: "passenger:/tmp/passenger.1.0.3
323/generation-0/request:", host: "crete.example.com"
Any other conf file you might need to solve this don't hesitate to ask.
Check out your sites-available and sites-enabled and see if your other rails app is included and configured properly. Also, check if these files are included in your nginx.conf
I'm hosing a rails application on digital ocean. Its working perfectly. I would like to host a Sinatra application on the same VPS. I have setup the nameservers and DNS.
My opt/nginx/conf/nginx.conf is:
worker_processes 1;
events {
worker_connections 1024;
}
http {
passenger_root /home/deploy/.rvm/gems/ruby-2.0.0-p0/gems/passenger-4.0.0.rc6;
passenger_ruby /home/deploy/.rvm/wrappers/ruby-2.0.0-p0/ruby;
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name domain1.com;
charset utf-8;
root /home/deploy/apps/domain1/current/public;
passenger_enabled on;
rails_spawn_method smart;
rails_env production;
}
server {
listen 80;
server_name domain2.com www.domain2.com;
charset utf-8;
root /home/deploy/apps/domain2-path/public;
passenger_enabled on;
rails_spawn_method smart;
}
}
Now when I go domain2.com it loads the application of domain1.com, what am I doing wrong.
PS: Domain1.com is rails applicion and Domain2.com is sinatra application.
You cannot do it only by defining another DNS address.
You should run the other app on different URL.
Then do something like this:
upstream rails {
server 127.0.0.1:8000;
}
upstream sinatra {
server 127.0.0.1:7000;
}
server {
location /rails {
proxy_pass http://rails;
}
location /sinatra {
proxy_pass http://sinatra;
}
}