Welcome! Log In Create A New Profile

Advanced

Unable to make my configuration work

Posted by imRahulSoni 
Unable to make my configuration work
October 12, 2015 07:57AM
My configuration looks like this...

server {
listen 80;
server_name 127.0.0.1 localhost;
location = /index.html {
root /etc/nginx/html/app1;
index index.html;
}

location / {
root /etc/nginx/html/app1;
index index.html;
}

location ^~ /common/ {
root /etc/nginx/html/common;
}
}

As you can see, I am trying to have different roots for different locations. Common folder is where I want to keep some common files. Unfortunately, with this configuration, I keep getting 404 for common. Index folder works as expected. If I copy the common folder inside app, it works as expected.

I wouldn't like to keep the common folder inside of app1 though. I am struggling big time with this configuration. Please help.
Re: Unable to make my configuration work
October 12, 2015 08:36AM
Where you want to end up is root+location, your last uri will now be /etc/nginx/html/common/common

location ^~ /common/ {
root /etc/nginx/html/other;
}

=> /etc/nginx/html/other/common

location ^~ /another/ {
root /etc/nginx/html/other;
}

=> /etc/nginx/html/other/another

nb. When ending a location with .../ you need to enter the URL with an ending / as well.

---
nginx for Windows http://nginx-win.ecsds.eu/
Re: Unable to make my configuration work
October 12, 2015 08:47AM
Thanks bunch. I tried what you suggested and part of it worked!

Really appreciate your help.



Edited 1 time(s). Last edit at 10/12/2015 08:48AM by imRahulSoni.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 155
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