[英]Nginx hosting a single Rails app on sub uri
Background: 背景:
Problem: 问题:
I need to host the rails app on a sub uri or context root path on the server behind the reverse proxy, so that when users navigate to the website, the url for the root path looks like this: 我需要在反向代理后面的服务器上的子uri或上下文根路径上托管rails app,这样当用户导航到网站时,根路径的url如下所示:
How would I set this up in nginx sites-enabled config file, and is there anything I would have to modify on the rails app to allow it to sever the correct paths to static content. 我如何在启用了nginx站点的配置文件中进行设置,并且我需要在rails应用程序上修改任何内容以允许它切断到静态内容的正确路径。
I strongly recommend to use Unicorn instead of Passenger. 我强烈建议使用Unicorn而不是Passenger。 You can set up both of them(Unicorn and Nginx) as reverse proxy.
您可以将它们(Unicorn和Nginx)设置为反向代理。 This link will be pretty good paper for you..
这个链接对你来说是相当不错的论文..
Again, you 'rewrite'(Nginx route feature) /rails_app to rails application's Unicorn socket file(usually using upstream). 再次,你'重写'(Nginx路由功能)/ rails_app到rails应用程序的Unicorn套接字文件(通常使用上游)。
See also below code snippets. 另请参见下面的代码段。
partial nginx.conf 部分nginx.conf
location ~* ^/(rails_app)/ {
root /your/rails/home;
index index.html index.htm;
proxy_pass http://socket_proxy_name;
}
partial snippet for proxy_pass proxy_pass的部分代码段
upstream socket_proxy_name{
server unix:/your/socket/paht.sock fail_timeout=0;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.