Just created a Laravel 7 application and transfered it to my new digital ocean droplet. Ive installed LEMP and everything needed for it to work.
However when I go to the server IP and access the home page '/' none of the assets (images,css,javascript) are being loaded. If I go to any other page on the application I get the error 403 Forbidden.
Nginx error.log shows a ton of these:
*47 access forbidden by rule, client: IP_ADDRESS(ive changed this to hide IP), server: IP_ADDRESS(ive changed this hide IP), request: "GET /images/logo.jpg HTTP/1.1", host: "138>2021/03/12 00:03:12 [error] 8059#8059:
My nginx file looks like this:
server {
listen 80;
server_name IP_ADDRESS; <------Changed this to hide IP
root /var/www/challenge/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.html index.htm index.php;
charset utf-8;
location / { try_files $uri $uri/ /index.php?$query_string; }
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ .php$ {
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /.(?!well-known).* { deny all; }
}
Any ideas?
Remove this line from your config:
location ~ /.(?!well-known).* { deny all; }