我的nginx配置如下:
upstream app_server {
server unix:/run/DigitalOceanOneClick/unicorn.sock fail_timeout=0;
}
server {
listen 80;
root /home/rails/rails_project/public;
server_name example.com www.example.com;
index index.htm index.html;
location / {
try_files $uri/index.html $uri.html $uri @app;
}
location ~* ^.+\.(jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|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;
proxy_read_timeout 180;
proxy_http_version 1.1;
proxy_set_header Connection "";
}
}
unicorn配置文件如下:
listen "unix:/run/DigitalOceanOneClick/unicorn.sock"
worker_processes 4
user "rails"
working_directory "/home/rails/rails_project"
pid "/run/DigitalOceanOneClick/unicorn.pid"
stderr_path "/var/log/unicorn/unicorn.log"
stdout_path "/var/log/unicorn/unicorn.log"
我经常收到“504 Gateway Time-out”错误。我对这个问题一无所知。服务器操作系统是带有rails5.1.3,nginx和unicorn的Ubuntu 14.04。谢谢。