我刚刚得到了VM,它安装了nginx、unicorn和一个新的rails应用程序。我看了nginx配置文件,我不明白它是如何连接到独角兽的,特别是因为似乎没有任何上游设置(这是大多数教程中说你需要的)。
以下是我的配置设置:
/home/unicorn/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"仅支持/etc/nginx/sites-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|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;
}
}服务器似乎在定义一个location @app,并将请求传递给http://app_server .我不知道它从哪里得到的app_server .这会是其他地方定义的上游吗?
在提供更多信息之前,本文的设置与我的vps完全相同。https://www.digitalocean.com/community/articles/how-to-1-click-install-ruby-on-rails-on-ubuntu-12-10-with-digitalocean
发布于 2013-08-08 11:26:03
通常,app_server将在另一个文件中定义为上游。例如,在我的debian系统上,我设置了一个类似于您的位置,指向一个名为www的上游
在我的/etc/nginx/sites-enabled目录中,有一个名为upstream_www_app的文件,其内容如下
upstream www {
server localhost:24910 fail_timeout=0 weight=5;
}24910是我的应用程序config/unicorn.rb中定义的端口,我的主nginx.conf包含sites-enabled目录中的所有文件。
https://stackoverflow.com/questions/18121934
复制相似问题