简体   繁体   English

如何配置nginx在域中使用Rails应用程序,在/ blog /中使用WordPress?

[英]How do I configure nginx to have a Rails app at a domain and WordPress at /blog/?

I've got a Rails app deployed via nginx/passenger. 我已经通过nginx / passenger部署了Rails应用程序。 It will have multiple domains pointing to it. 它将有多个指向它的域。

I'm wondering if it's possible to configure nginx so that any URL that matches [somedomain.com]/blog/ will be servered by PHP/WordPress located in a different directory. 我想知道是否可以配置nginx,以便任何与[somedomain.com] / blog /匹配的URL都可以由位于不同目录中的PHP / WordPress服务器提供。

So, for example: 因此,例如:

domain1.com, domain2.com, & domain2.com/some-resource/1 point to the Rails app at /var/rails/mainapp/ domain1.com,domain2.com和domain2.com/some-resource/1指向位于/ var / rails / mainapp /的Rails应用程序

but domain1.com/blog/ goes to /var/sites/domain1.com/ 但domain1.com/blog/转到/var/sites/domain1.com/

and domain2.com/blog/ goes to /var/sites/domain2.com/ 和domain2.com/blog/转到/var/sites/domain2.com/


server {
  location /blog {
    alias /var/sites/domain1.com/;
  }
  location / {
  }
}

You need define you /blog before / location 您需要在/位置之前/ blog定义您

Here is my config. 这是我的配置。 Hope it helps someone. 希望它可以帮助某人。

# Redirect all requests containing 'www.your-website.ru'
# to 'your-website.ru'
server {
listen 80;
server_name  www.your-website.ru;
rewrite ^(.*) http://your-website.ru$1 permanent;
}

server {
listen       80;
server_name  your-website.ru;

access_log  logs/your-website.ru.log;

root /path-to-your-website.ru/current/public;

#####################
# Rails
#####################
location / {
rails_env production;       # this is a production server
passenger_enabled on;       #

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将Rails应用和wordpress博客放在同一个域中? - How can I put a rails app and a wordpress blog on the same domain? 在Rails应用程序中,如何在appname.com/blog(而不是blog.appname.com)上直播Tumblr或Wordpress博客? - In a Rails app, how can I have a Tumblr or Wordpress blog live at appname.com/blog instead of blog.appname.com? 如何使Rails 3应用程序和Wordpress博客在同一域上工作? - How to make Rails 3 app and Wordpress blog work on same domain? 如何配置Nginx在同一域上同时服务Rails应用程序和Angular - How to configure Nginx to serve both Rails app and Angular on same domain 如何配置nginx代理到rails应用程序?所以我不必说domain.com:port - How to config nginx to proxy to rails app? so that i dont have to say domain.com:port 如何在 Nginx 和 Unicorn 上为 Rails 应用程序配置 SSL? - How do I configure SSL on Nginx and Unicorn for Rails application? 如何将Rails应用的Nginx配置为子域? - How configure nginx for rails app as subdomain? 如何在Heroku的Rails应用程序中的子URI上运行Wordpress Blog - How to run Wordpress Blog on a Sub URI within a Rails App on Heroku 为多个Rails应用程序配置NGINX - Configure NGINX for multiple rails app 如何在rails 4应用程序上设置ssl? (nginx +乘客) - How do I setup ssl on a rails 4 app? (nginx + passenger)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM