0
votes

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

1

1 Answers

1
votes

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