我们为Nginx和puma的rails应用程序设置了生产服务器。我们想部署我们的轨道应用程序在子uri和我们想要把WordPress的主页,定价页面等主要域名在域的sub uri处部署rails应用程序
我们如何配置我们的轨道,它可以在Sub uri上运行,其中有Devise gem身份验证。我们需要改变我们的路线吗?
nginx和puma的配置是什么?
在此先感谢!
我们为Nginx和puma的rails应用程序设置了生产服务器。我们想部署我们的轨道应用程序在子uri和我们想要把WordPress的主页,定价页面等主要域名在域的sub uri处部署rails应用程序
我们如何配置我们的轨道,它可以在Sub uri上运行,其中有Devise gem身份验证。我们需要改变我们的路线吗?
nginx和puma的配置是什么?
在此先感谢!
的配置首先把你需要的子URI路径在application.rb
即主要
...
config.relative_url_root = "/main"
...
在config.ru
,添加这些行。
require ::File.expand_path('../config/environment', __FILE__)
map SampleApplication::Application.config.relative_url_root || "/" do
run Rails.application
end
在production.rb
,加入下面的行。
# Enable serving of images, stylesheets, and JavaScripts from an asset server
config.action_controller.asset_host = "YOUR_DOMAIN_NAME/main"
# ActionMailer Config
config.action_mailer.default_url_options = {
:host => "YOUR_DOMAIN_NAME",
:only_path => false,
:script_name => "/main"
}
在nginx的配置文件中,添加这些行
location /main {
alias /var/deploy/sample_application/current/public;
try_files $uri @main;
}
location @main {
proxy_http_version 1.1;
chunked_transfer_encoding off;
proxy_buffering off;
proxy_cache off;
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://puma_sample_application;
}
不,你不应该配置rails应用程序。 其实你可以改变你的nginx配置。
它应该向您的WordPress应用程序和子域请求代理根域请求到您的Rails应用程序。
退房这个问题,得到的nginx How configure nginx for rails app as subdomain?
的only_path:假和SCRIPT_NAME: 'my_sub_uri' 是钢轨的ActionMailer生成从助手正确的URL的键。 – NoelProf 2018-01-10 01:12:55