Tag: nginx

从域发送请求到特定Rails引擎

我在Rackspace VPS上运行了一个rails应用程序。 堆栈是rails3 + unicorn + nginx + mysql。 有一个主域使用proxy_pass将流量直接发送到unicorn套接字。 我开发了一种安装在/digital下的新引擎。 现在,人们可以通过http://primarydomain.com/digital与该引擎进行交互。 我想托管一个新的域名,直接将请求转发到/digital ; 不是根引擎。 因此,例如,以下请求将产生等效结果: http://primarydomain.com/digital/splash http://alternatedomain.com/splash 在完美的世界中,引擎将是一个单独的应用程序。 我想表现得好像单独的域是一个单独的应用程序,虽然它真的是一个挂载的引擎。 这是routes.rb样子: Company::Application.routes.draw do root :to => ‘spree/home#splash’ ActiveAdmin.routes(self) mount Core::Engine, :at => ‘/’ mount Another::Engine, :at => ‘/digital’ end 我需要什么rails + nginx配置来实现这个function?

ConnectionNotEstablished之后在JRuby中有一个multithreading环境

我有Rails(4.2.6)应用程序,我使用Thread(s)进行Rufus :: Scheduler引起的后台数据处理。 我在开发环境中有工作应用程序,但是当我在nginx +乘客上将它移动到生产时,我得到exceptionActiveRecord :: ConnectionNotEstablished ,即使没有足够的负载。 从Threads执行的ActiveRecord :: Base后代的所有调用都包含在内 ActiveRecord::Base.connection_pool.with_connection{} 我之前从未使用multithreading环境,但在对问题进行一些调查后,我建议可能就是这个问题。 在JRuby下尝试它是否合理,哪种包含是优先的? 主机系统是Ubuntu 14.04 x86_64。

使用nginx,passenger和capistrano部署Rails应用程序

我正在部署我的第一个rails应用程序。 我这样做有些麻烦。 我将描述我到目前为止所做的事情。 1)我通过gorails.com正确配置了所有内容 2)我正在尝试将其部署在Digital Ocean上 3)我进行了cap deploy production ,最终结果成功,中间有一些失败。 4)我启动了nginx服务器 5)在我的浏览器中它给了我500错误。 6)我检查了我的production.log ,它显示了它运行的所有迁移和种子。 它完美地创建了表格(正如我在我的数据库中检查过的那样)。 7)我检查了nginx error.log ,结果显示index.html缺失。 8)所以为了检查,我在公共目录中添加了index.html文件,浏览器正确显示了内容。 9)但是我的登陆页面是家庭控制器中的index.html.erb,所以在路径文件中我做了一些修改但是浏览器的输出没有变化。 10)我注意到error.log和production.log没有立即更新。 我不知道为什么。 11)我需要帮助让nginx显示我的index.html.erb文件并将其与rails app连接。 数据库配置正确。 12)我的nginx配置文件是: server { listen 80 default_server; server_name digital_ocean_ip; passenger_enabled on; rails_env production; root /home/myapp/myapp/current/public; # redirect server error pages to the static page /50x.html error_page 500 502 503 504 /50x.html; […]

在rails 3.2中使用nginx而不是rails来提供static_assets

我最近部署了一个基于SpreeCommerce平台的网站。 我正在使用nginx,并希望nginx能够提供我的静态资产。 我遇到的问题是,当用户在网站上为产品上传新照片时,图像看起来可以正确保存(文件位于服务器上),但它们不会被提供给浏览器。 我可以通过将production.rb更改为config.serve_static_assets = true而不是false并将图片重新上传到现有产品来暂时解决此问题。 但是这有资源而不是nginx服务 – 而不是我想要发生的事情。 这是我目前的nginx配置文件: user spree; worker_processes 4; pid /var/run/nginx.pid; events { worker_connections 1024; multi_accept on; } http { types_hash_bucket_size 512; types_hash_max_size 2048; sendfile on; tcp_nopush on; tcp_nodelay 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_proxied any; gzip_min_length 500; gzip_types text/plain text/css application/json […]

rbenv乘客无法加载此类文件 – bundler / setup

我的乘客是作为gem安装的。 Nginx由passenger-install-nginx-module 。 ruby 2.1.1有3个gemsets,rubygemset rails4_1是这个应用程序的正确。 其他post显示类似的问题( 1,2,3 ),但没有一个解决我的问题。 [ 2014-09-29 14:29:17.1212 13182/7f32e5938700 Pool2/Implementation.cpp:287 ]: Could not spawn process for application /home/canoe/apps/app1: An error occured while starting up the preloader. Error ID: b57602d4 Error details saved to: /tmp/passenger-error-jcmrkH.html Message from application: cannot load such file — bundler/setup (LoadError) /home/canoe/.rbenv/versions/2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require’ /home/canoe/.rbenv/versions/2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require’ /home/canoe/.rbenv/versions/2.1.1/gemsets/rails4_1/gems/passenger-4.0.52/lib/phusion_passenger/loader_shared_helpers.rb:263:in `block in […]

nginx剥离最后修改和if-modified-since标头,但我的rails应用程序需要它们

我的Rails 3.2应用程序使用 – 通过#stale? – If-Modified-Since请求中的HTTP头和响应中的Last-Modified头决定是否应该动态生成一些数据。 这在开发中非常有效(无论是使用webrick还是unicorn_rails),因为curl -D headers.txt显示如果提供了正确的If-Modified-Since值,则发送304响应,而Last-Modified标头另外发送请求数据。 不幸的是,一旦部署在nginx之后, If-Modified-Since (提供正确的头部值)都不会传递给unicorn – 因此Rails应用程序 – 也不会Last-Modified传播到客户端:无条件地生成请求并且响应永远不会包含合适的标题。

使用Passenger / Capistrano部署到Nginx服务器后未显示的图像

嗨我正在使用Capistrano将我的第一个Rails应用程序部署到Ubuntu 16服务器,除了图像没有在生产环境中显示外,一切都很顺利。 在生产服务器上,映像位于以下路径中: /myapp/current/public/assets 但是如果我在浏览器中看到这个,我的破碎图像链接给了我这个(见图片),这是标题图像的断开链接。 奇怪的是, /myapp/current/public/assets中有一个.svg文件,它在浏览器中完美显示,在下图中是显示的路径 这是我的Capfile # Load DSL and set up stages require “capistrano/setup” # Include default deployment tasks require “capistrano/deploy” set :rbenv_type, :user # or :system, depends on your rbenv setup set :rbenv_ruby, ‘2.3.1’ require ‘capistrano/rbenv’ require ‘capistrano/bundler’ require ‘capistrano/rails’ # Load custom tasks from `lib/capistrano/tasks` if you have any defined […]

单个IP上的多个rails应用程序(nginx +乘客)

我正在寻找在一台服务器上提供多个rails应用程序的方法。 我上传了其中一个应用程序,它运行正常。 但是,只要我为新应用程序创建nginx配置,它就会崩溃第一个。 我找不到合适的指南。 如果您有任何建议,请分享。

Devise无法登录Google Chrome

我正在使用Devise gem在Ruby on Rails Web应用程序上进行用户身份validation。 这个过程非常直接。 但是,在添加Nginx和ssl证书后,我可以在Mozilla Firefox中登录但无法登录Google Chrome的应用程序。 到目前为止,我能找到的唯一跟踪是我的环境日志文件中的这几行: Processing by Devise::SessionsController#create as HTML Parameters: {“utf8″=>”✓”, “authenticity_token”=>”==”, “user”=>{“email”=>”email@test.com”, “password”=>”[FILTERED]”, “remember_me”=>”0”}, “commit”=>”LOG IN”} HTTP Origin header (https://) didn’t match request.base_url (: https://:80) 我的Nginx配置为/ location / { proxy_pass http://127.0.0.1:3000; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_set_header X-Forwarded-Proto: $scheme; } 注意:如果我删除了proxy_set_header […]

capistrano部署后,ec2服务器中缺少puma.sock

在通过capistrano将生产ruby on rails项目部署到ec2上的实例后,我在nginx错误日志中收到以下错误。 亚马逊公共主机显示502 Bad Gateway nginx / 1.10.0(Ubuntu)。 我按照https://www.sitepoint.com/deploy-your-rails-app-to-aws/上的教程进行操作。当我运行cap生产部署时,似乎没有创建puma.sock。 2017/06/28 01:09:57 [crit] 12802#12802: *1 connect() to unix:/home/deploy/app_name/shared/tmp/sockets/puma.sock failed (2: No such file or directory) while connecting to upstream, client: 173.198.30.2, server: localhost, request: “GET / HTTP/1.1”, upstream: “http://unix:/home/deploy/app_name/shared/tmp/sockets/puma.sock:/”, host: “host” 以下是我的deploy.rb set :application, ‘app_name’ set :repo_url, ‘git@github.com:github_account/app_name.git’ # Edit this to match your repository […]