nginx redirecting to parent directory not sub drirectory

nginx default config file

server {
  listen          80;
  server_name     domain.com;
  root            /var/www/html/laravel5-1.0/;
  index       index.php;

  location / {
   try_files $uri $uri/ /index.php;
   proxy_redirect off;
   proxy_set_header Host $host:$server_port;
   proxy_set_header X-Real-IP $remote_addr;
   proxy_set_header X-Forwarded-Host $host;
   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

   #proxy_cache web_cache;
   add_header X-Proxy-Cache $upstream_cache_status;

   proxy_pass http://localhost:8081/;
  }


  # CSS and Javascript
  location ~* \.(?:css|js)$ {
    expires 1y;
    access_log off;
    add_header Cache-Control "public";
  }

}

Problem: nginx pointing to www directory not the laravel5-1.0 directory application type is laravel

laravel5 is the public directory for my application nginx and apache running on the same virtual host machine nginx port 80 apache2 8081

please help me to redirect my page access to laravel5-1.0 directory

Answers


try_files does just that, it checks for $uri if it doesn't find that, it will do an internal redirect to /index.php before the proxy_pass. So if you remove the line try_files $uri $uri/ /index.php;

It will reach the proxy_pass to http://localhost:8081/

Doc: http://nginx.org/en/docs/http/ngx_http_core_module.html#try_files


Need Your Help

HTML font size changes after loading alert window through Javascript

javascript php

I have a basic PHP web form to save data into mssql database.

How to add children to QGraphicsItem

c++ qt qgraphicsitem

I have the following code, where I'm trying to have two rectangles, and then inside each, display "sub" rectangles (this is the code for one parent and one child)