views:

53

answers:

2

I've got a Rails app deployed via nginx/passenger. 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.

So, for example:

domain1.com, domain2.com, & domain2.com/some-resource/1 point to the Rails app at /var/rails/mainapp/

but domain1.com/blog/ goes to /var/sites/domain1.com/

and domain2.com/blog/ goes to /var/sites/domain2.com/

+1  A: 

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

You need define you /blog before / location

shingara
Ok, thanks ... but how do I base the alias on the domain? (since there will be multiple domains)
Callmeed
A: 

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;       # 
Konstantin