0

I have the following nginx.conf

http {

    root /home/aissy/Documents/web;
    access_log /home/aissy/Documents/web/access.log;
    error_log /home/aissy/Documents/web/error.log;
    autoindex on;

server {
    listen localhost:88;

    location / {root /;}
    location /exp/ {
    root /test;
    }
    location /togoogle/ {
    proxy_pass https://www.google.com;
    }
   }
}

events {}

for prefix exp, i want to access test and for prefix togoogle, i want to redirect to google.com, yet

when I request such that

curl localhost:88/togoogle && curl localhost:88/exp

I get 404 everywhere.

  • The URI `/exp` and `/exp/` are different. You have defined a `location` using the latter, and are testing using the former. Check the error log. Which file are you expecting Nginx to return when you use `curl localhost:88/exp` and what is its full path? – Richard Smith Aug 06 '21 at 06:47
  • @RichardSmith it's the dir `~/Documents/web/test`. – user1094822 Aug 06 '21 at 09:14
  • `root /test;` will not point to that folder. You need to use the full path, e.g. `root /home/aissy/Documents/web/test;`. By default, Nginx will be looking for a file called `/home/aissy/Documents/web/test/exp`, or if `exp` is also a folder then `/home/aissy/Documents/web/test/exp/index.html` – Richard Smith Aug 06 '21 at 09:49

0 Answers0