Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

403 Forbidden on nginx/1.4.6 (Ubuntu) - Laravel

Tags:

I keep getting 403 Forbidden

enter image description here


My settings:

/etc/nginx/sites-available/default

default

server {         listen   80;           root home/laravel-app/;          index index.php index.html index.htm;          server_name example.com;          location / {                 try_files $uri $uri/ /index.html;         }          error_page 404 /404.html;          error_page 500 502 503 504 /50x.html;         location = /50x.html {               root /usr/share/nginx/www;         }          # pass the PHP scripts to FastCGI server listening on the php-fpm socket         location ~ \.php$ {                 try_files $uri =404;                 fastcgi_pass unix:/var/run/php5-fpm.sock;                 fastcgi_index index.php;                 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;                 include fastcgi_params;          }  } 

Update

I followed this instruction : here


Any hints/suggestions on this will be a huge help !

like image 956
code-8 Avatar asked Oct 30 '15 19:10

code-8


People also ask

How do I fix 403 Forbidden Nginx ubuntu?

However, if the specified index files are not in the directory, Nginx will return 403 forbidden error. One way to resolve this issue is to add the index file specified in the configuration file or add the available index file to the config file.

How do I fix PHP Error 403 Forbidden?

php. If there is no such page on your website, the visitors can encounter a 403 Error. Resolve this by uploading an index page to your httpdocs or public_html directory. If you already have a homepage named other than index, you can rename it or set up a redirect in your .

Does Laravel run on Nginx?

The Nginx server will serve the application. It will establish a demo Laravel application using the MySQL database. This guide requires some preconditions. We assume that you already have a properly configured Ubuntu 20.04 server up and running.

How do I trigger a 403 error?

The most common cause of a 403 Forbidden Error is simply inputting an incorrect URL. As discussed before, many tightly secured web servers disallow access to improper URLs. This could be anything from accessing a file directory to accessing a private page meant for other users.


1 Answers

You need to specify an absolute path for your root directive. Nginx uses the directory set at compile time using the --prefix switch. By default this is /usr/local/nginx.

What this means is that your root, which is currently set to root home/laravel-app/ causes nginx to look for files at /usr/local/nginx/home/laravel-app/ which presumably isn't where your files are.

If you set your root directive to an absolute path such as /var/www/laravel-app/public/ nginx will find the files.

Similarly you'll note that I added /public/ to the path above. This is because Laravel stores it's index.php file there. If you were to just point at /laravel-app/ there's no index file and it'd give you a 403.

like image 63
Ben Swinburne Avatar answered Oct 12 '22 22:10

Ben Swinburne