Welcome! Log In Create A New Profile

Advanced

multiple roots for multiple sites

John Magolske
May 14, 2010 06:36PM
Hi,

I'm working on multiple sites & would like to specify different
roots for each one so that identical absolute urls such as
<a href="/index.html">Home</a> on each site don't all get
directed to the same /usr/local/nginx/html/index.html

ie,

navigate to http://localhost/site1 & the root will be
/usr/local/nginx/html/site1

navigate to http://localhost/site2 & the root will be
/usr/local/nginx/html/site2

I tried this:

location /site1/ {
root /usr/local/nginx/html/site1;
index index.html index.htm;
}

But navigating to http://localhost/site1 gets '404 Not Found'.
Without the above location directive, the site comes up fine
(other than than the aforementioned issue with absolute urls).

At this point I'm only running the sites locally on my laptop.

My nginx.conf looks like this:

worker_processes 1;
events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;

server {
listen 80;
server_name localhost;

location / {
root html;
index index.html index.htm;
}

location /site1/ {
root /usr/local/nginx/html/site1;
index index.html index.htm;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}


Being new to nginx, I realize I'm probably overlooking something(s)
obvious with respect to how location directives & root works here.

TIA for any help,

John


--
John Magolske
http://B79.net/contact

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

multiple roots for multiple sites

John Magolske May 14, 2010 06:36PM

Re: multiple roots for multiple sites

Fernando Perez May 14, 2010 06:36PM

Re: multiple roots for multiple sites

John Magolske May 14, 2010 07:04PM

Re: multiple roots for multiple sites

Fernando Perez May 15, 2010 06:18AM

Re: multiple roots for multiple sites

Maxim Dounin May 14, 2010 07:32PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 307
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready