Ruby on rails 3 502网关错误(nginx&x2B;独角兽&x2B;数字海洋)
我花了几个小时来解决这个问题,但仍然没有成功。我在浏览器中看到的错误是: POST/users 502(坏网关) 我知道这是设置nginx和unicorn的问题,但我无法解决它。顺便说一下,我使用digital ocean部署了我的代码。这是我的配置文件Ruby on rails 3 502网关错误(nginx&x2B;独角兽&x2B;数字海洋),ruby-on-rails-3,nginx,unicorn,gateway,digital-ocean,Ruby On Rails 3,Nginx,Unicorn,Gateway,Digital Ocean,我花了几个小时来解决这个问题,但仍然没有成功。我在浏览器中看到的错误是: POST/users 502(坏网关) 我知道这是设置nginx和unicorn的问题,但我无法解决它。顺便说一下,我使用digital ocean部署了我的代码。这是我的配置文件 独角兽配置(nginx.conf): Unicorn配置文件(/var/nginx/Unicorn.conf): 我使用的是Rails 3。如果有人知道这个问题,请告诉我。我花了3个小时没有任何进展。谢谢你也能提供你为unicorn提供的配置
独角兽配置(
nginx.conf
):
Unicorn配置文件(/var/nginx/Unicorn.conf
):
我使用的是Rails 3。如果有人知道这个问题,请告诉我。我花了3个小时没有任何进展。谢谢你也能提供你为unicorn提供的配置吗(你提供的文件都是为nginx提供的)。它应该是什么样子的一个例子是在这里“配置服务器”条目的第一部分:我遇到了这个问题,试图找出为什么在使用Digital Ocean的一键式安装以及使用不同版本的Ruby后,我会出现502个错误 我通过阅读本指南找到了答案: 我的问题是《指南》中的以下内容: 一旦获得默认使用的Ruby的位置, 将/etc/default/unicorn路径名更改为包含/usr/local/rvm/rubies 新安装的子文件夹和/usr/local/rvm/gems子文件夹 独角兽的版本和位置
希望这对某人有所帮助日志文件中的错误说明了什么?
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
server_names_hash_bucket_size 64;
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;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
# Load config files from the /etc/nginx/conf.d directory
# The default server is in conf.d/default.conf
include /etc/nginx/conf.d/*.conf;
fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
}
upstream unicorn {
server unix:/tmp/unicorn.sock fail_timeout=0;
}
server {
listen 80;
listen 443 ssl;
ssl_certificate /root/certs/server.crt;
ssl_certificate_key /root/certs/server.key;
client_max_body_size 4G;
keepalive_timeout 15;
root /var/www/quoine/current/public;
try_files $uri @unicorn;
location ~ ^/assets|app/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
location = /app/ {
rewrite $uri $uri/index.html;
}
location = /app/index.html {
add_header Pragma "no-cache";
add_header Cache-Control "no-cache, no-store, max-age=0, must-revalidate";
add_header Expires "Fri, 01 Jan 1990 00:00:00 GMT";
}
location @unicorn {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect off;
proxy_pass http://unicorn;
}
if (-f $document_root/system/maintenance.html) {
return 503;
}
error_page 500 502 504 /500.html;
location = /500.html {
root /var/www/quoine/current/public;
}
error_page 503 @maintenance;
location @maintenance {
rewrite ^(.*)$ /system/maintenance.html break;
}
}