Why is Rails-home-image not shown on unicorn and nginx?
Asked Answered
W

1

0

I want set up rails on unicorn on nginx. Setup unicorn and nginx and modify nginx.conf like following code. However, on the home view of rails, rails-default-image is not shown as the attached picture. Please help!!

Versions; ruby:2.4.0 p0, rails:5.0.2, nginx: 1.10.2
*Nginx is located on amazon linux AMI

Follwing code is nginx.conf

user ec2-user; 
worker_processes 1
events {
    worker_connections 1024;
}

http {

#    sendfile            on;
#    tcp_nopush          on;
#    tcp_nodelay         on;
#    keepalive_timeout   65;
#    types_hash_max_size 2048;

upstream unicorn {
  server  unix:/myPathTo/tmp/unicorn.sock;
}

server {
    listen       my-port;
    server_name  my-server;

    access_log  /var/log/access.log;
    error_log   /var/log/error.log;

    root    my-root
#   index   index.html;
    client_max_body_size 4G; #100m;
    error_page  404              /404.html;
    error_page  500 502 503 504  /500.html;
    try_files   $uri/index.html $uri @unicorn;

    location @unicorn {
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $http_host;
            proxy_pass http://unicorn;
            }
      }
}

Following content is error.log

2017/04/23 06:45:40 [crit] 29912#0: *1 open() 
"/var/lib/nginx/tmp/proxy/1/00/0000000001" failed (13: Permission 
denied) while reading upstream, client: (clientserver), server: 
(my-server), request: "GET / HTTP/1.1", upstream: 
"http://unix:/pathTo/tmp/unicorn.sock:/", host: 
"(my-server)"

Shown default view of rails: enter image description here

Wampler answered 23/4, 2017 at 7:28 Comment(3)
Note this line: "/var/lib/nginx/tmp/proxy/1/00/0000000001" failed (13: Permission denied). The user that is running the server is not allowed to read from the tmp folder.Gadid
I checked the permission authority and found that only nginx is allowed to access /var/lib/nginx and /var/lib/nginx/tmp. I tried to change permission authority using chmod. But, I can't. Please teach me.Wampler
I could change permission authority by chmod. Thank you very much. But in this time, I use chmod 777 nginx. What authority you recommend?Wampler
F
0

Use the following command to fix the permission of nginx folder.

sudo chmod -R 775 /var/lib/nginx/tmp
Fourposter answered 9/10, 2021 at 7:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.