我正在从nginx +乘客迁移到nginx +独angular兽,我已经达到了一点,我有点卡住了。
当我试图查看我的testing服务器时,除了404页面,我什么都没有。 我确定我的虚拟主机configuration有一些东西,但是我只是没有看到问题所在。
任何帮助,这是非常感谢。
这是我的vhost文件的当前版本
upstream unicorn-staging { server unix:/data/appname/staging/current/tmp/sockets/unicorn-staging.sock fail_timeout=0; } server { listen 80 deferred; listen 443; ssl on; root /data/appname/staging/current/public; server_name foo; access_log /data/appname/staging/current/log/unicorn-staging-access.log; error_log /data/appname/staging/current/log/unicorn-staging-error.log; client_max_body_size 4G; ssl_certificate /data/appname/staging/shared/certs/appname.crt; ssl_certificate_key /data/appname/staging/shared/certs/appname.key; location / { proxy_pass http://unicorn-staging; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto https; # for SSL, add this client_max_body_size 10m; client_body_buffer_size 128k; proxy_connect_timeout 90; proxy_send_timeout 90; proxy_read_timeout 90; proxy_buffer_size 4k; proxy_buffers 4 32k; proxy_busy_buffers_size 64k; proxy_temp_file_write_size 64k; index index.html index.htm; } location ~ \.(jpg|png|mp3|ogg)$ { valid_referers server_names; if ($invalid_referer) { return 403; } } location ~ \.(jpg|png|mp3|ogg|js|css|html|gif)$ { gzip_static on; expires max; add_header Cache-Control public; } location ~ ^/(images|javascripts|stylesheets|assets)/ { root /data/appname/staging/current/public; # for asset pipeline and other static files expires max; break; } # redirect server error pages to the stat error_page 500 502 503 504 /50x.html; }
您的独angular兽configuration很可能没有正确设置。
当nginx运行时,这发生在我的服务器上,但独angular兽不是。 原因是nginx尝试将请求传递给套接字,但是独angular兽不在那里接收它。
默认情况下,独angular兽只监听端口8080。 您可以更改您的独angular兽设置,以侦听不同的端口或套接字。
如果你使用的是独angular兽configuration文件( config/unicorn.rb ),那么在这个文件中,你应该有类似的东西(注意你将不得不改变套接字path):
listen File.expand_path("tmp/sockets/unicorn.sock", RAILS_ROOT)
为了debugging目的,我也让它听一个端口。
listen File.expand_path("tmp/sockets/unicorn.sock", RAILS_ROOT) listen 3000, :tcp_nopush => true
要在生产Web服务器上启动独angular兽,需要运行类似于以下命令的命令:
bundle exec unicorn -E production -c config/unicorn.rb
这使用独angular兽configuration文件。 有关示例configuration文件,请参见http://unicorn.bogomips.org/Unicorn/Configurator.html 。
如果您不使用独angular兽configuration文件,则需要以下格式的命令行开关:
-l, --listen ADDRESS
例如:
bundle exec unicorn -l tmp/sockets/unicorn.sock
请注意,我正在使用相对path,因为我使用的pwd是rails根目录。