1

ワンクリック Ubuntu 12.10 インストール ドロップレットを使用して、DigitalOcean の Rails 4 で開発されたモバイル アプリの API をホストしています。したがって、nginx と Unicorn は事前に構成され、実行されています。Web ブラウザーで Rails パブリック フォルダーからファイルを開こうとすると、機能します。

しかし、ファイルで定義されている他のパスを使用しようとすると、routes.rb答えが得られません。私の要求は、タイムアウトするまでロードされます。rails s -e productionサーバーで入力すると、これが変わります。その後、すべてが期待どおりに機能します。したがって、nginx か何かの問題に違いありません。私は何が欠けていますか?

これが私のnginxsites-enabled/defaultファイルの内容です(それが探すべきものかどうかはわかりませんが、多分):

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|mid$
    location ~* ^.+\.(jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rt$
            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;
     }

}

更新:nginx.confこれが役立つ場合に備えて、これが私のファイルです:

user www-data;
worker_processes 4;
pid /var/run/nginx.pid;

events { worker_connections 1024; }

http {
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    server_tokens off;

    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

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

    gzip on;
    gzip_disable "msie6";
    gzip_types text/plain text/xml text/css text/comma-separated-values;
    upstream app_server { server 127.0.0.1:8080 fail_timeout=0; }

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}

更新 2:そしてここに私のunicorn.confファイル:

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"
4

1 に答える 1

0

私は同じ問題を抱えていてbundle install、アプリのルート (digitalocean ドロップレット上) で実行すると問題が解決しました。それをカピストラーノスクリプトに組み込む必要があると思います

于 2014-02-03T21:30:33.907 に答える