3

I'm trying to set up Laradock for my Laravel projects. I started with a new laravel project just to test things before trying with my current projects. I followed the tutorial but somewhere during the steps I must have messed something up I think because when I surf to the URL I get a "404 not found nginx". Someone experienced this before or knows what might be wrong? Thanks in advance!

404 error in browser

My example.conf in /var/wwwlaradock/nginx/sites

server {

listen 80;
listen [::]:80;

server_name example.local;
root /var/www/example/public;
index index.php index.html index.htm;

location / {
     try_files $uri $uri/ /index.php$is_args$args;
}

location ~ \.php$ {
    try_files $uri /index.php =404;
    fastcgi_pass php-upstream;
    fastcgi_index index.php;
    fastcgi_buffers 16 16k;
    fastcgi_buffer_size 32k;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
}

location ~ /\.ht {
    deny all;
}

location /.well-known/acme-challenge/ {
    root /var/www/letsencrypt/;
    log_not_found off;
}

error_log /var/log/nginx/laravel_error.log;
access_log /var/log/nginx/laravel_access.log;
}

My hosts file

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1   localhost
255.255.255.255 broadcasthost
::1             localhost
127.0.0.1   example.local

The name of my laravel project is "example" and is located in /var/www

Jasper
  • 83
  • 2
  • 11

2 Answers2

1

I had the same problem.

The issue was in my mistake in parameter "root" in nginx's [your-name].conf file.

It should match the path shown when you log in the laradock "workspace" (with "docker-compose exec workspace bash"), e.g. "/var/www".

In your case it looks like should be string

root /var/www/public

instead of

root /var/www/example/public

Guru777
  • 11
  • 1
0

The error occured because of invalid naming in laradock/nginx/sites/

before: laradock/nginx/sites/domain.laravel

after: laradock/nginx/sites/domain.laravel.conf

worked for me!

Murod
  • 22
  • 1
  • 6