The current application that I run works fine on my ubuntu server. But now I had to configure the Red Hat Enterprise Linux 5.5 server to deploy the application, and I am encountering some problems. First of all, some specifications:
- rails version: 3.2.11
- ruby: 1.9.3-p194
- http server nginx + unicorn
- ruby environment management with rbenv
- deployment method: capistrano
My nginx.conf and unicorn configuration file is based on a Ryan Bate video. Therefore, I was able to configure almost all the settings. I can deploy, connect to the database, etc. However, when I visit the page of my application, all assets are not loaded. And when I enter my console, he says that they failed due to a 403 Forbidden error. I checked and the assets are in the right place: apps / my_app / shared / assets. But I keep getting this 403 error.
What I have tried so far:
- checks access rights to parent folders and actual asset files. All of them had reading rights for everyone.
- changed
config.assets.compileto true - nginx unicorn: 403, conf.d symlinking nginx /etc/nginx/conf.d, .../sites-enabled
, 403?
1: /etc/nginx/nginx.conf
, , , nginx.conf(/etc/nginx) ( nginx):
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name _;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
include /etc/nginx/conf.d/*.conf;
}
, , /etc/nginx nginx.conf nginx.conf.default, - ? , ?
2: nginx
nginx. , , chmod?
2013/03/24 20:50:53 [error] 10851#0: *5 open() "/home/webapp/apps/my_app/current/public/assets/application-db22bc3811b126e586f5e82e794e7ee4.css" failed (13: Permission denied)
3: /etc/nginx/nginx.conf
user nginx;
worker_processes 2;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log;
sendfile on;
keepalive_timeout 60;
gzip on;
include /etc/nginx/conf.d/*.conf;
server {
listen 80 default deferred;
root /home/webapp/apps/my_app/current/public;
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri @unicorn;
location @unicorn {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://unicorn;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
}