Trying to deploy my first rails app on a vps. I have followed the instructions in the following setup.
But my site gets a 504 Gateway Time-out.
In the nginx log I get the following:
2013/10/16 03:10:45 [error] 19627#0: *82 connect() failed (111: Connection refused) while connecting to upstream, client: 121.218.167.90, server: _, request: "GET / HTTP/1.1", upstream: "http://162.243.39.196:8080/", host: "162.243.39.196"
And when I try to run unicorn I get the following
E, [2013-10-16T04:26:28.530019 #30087] ERROR -- : adding listener failed addr=0.0.0.0:8080 (in use)
My nginx default file has the following
server {
listen 80;
root /home/rails/public;
server_name _;
index index.htm index.html;
location / {
try_files $uri/index.html $uri.html $uri @app;
}
location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|mp3|flv|mpeg|avi)$ {
try_files $uri @app;
}
location @app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://app_server;
}
}
My /home/unicorn/unicorn.conf has
listen "127.0.0.1:8080"
worker_processes 2
user "rails"
working_directory "/home/rails"
pid "/home/unicorn/pids/unicorn.pid"
stderr_path "/home/unicorn/log/unicorn.log"
stdout_path "/home/unicorn/log/unicorn.log"
Thanks for your help.
You are missing an upstream block where you refer to in proxy_pass http://app_server;
. You can put it above the server block like this.
upstream app_server {
server 127.0.0.1:8080 fail_timeout=0;
}
server {
listen 80;
root /home/rails/public;
server_name _;
index index.htm index.html;
...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.