Ad

Nginx With Fresh Laravel 5.3 In Laravel Forge + DigitalOcean Always Returns 404 Not Found

- 1 answer

I have a bitbucket repository with a fresh Laravel 5.3 installation.

I have set up and connected a DO droplet to Laravel Forge. I have done everything with default settings. Nothing changed.

It is all (aparently) set up:

  • I can access through SSH to the droplet (using my private SSH key)
  • I can remotely access to the MySQL database, etc.

Everything except nginx. When I access the server public IP or the domain name (I have also configured the A record on my domain to point to the Droplet machine), I always get a 404 not found error...

Here is the default nginx configuration file that I have (nothing changed so far):

# FORGE CONFIG (DOT NOT REMOVE!)
include forge-conf/api.symaps.com/before/*;

server {
    listen 80;
    listen [::]:80;
    server_name api.symaps.com;
    root /home/forge/api.symaps.com/public;

    # FORGE SSL (DO NOT REMOVE!)
    # ssl_certificate;
    # ssl_certificate_key;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM
    SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-
    ES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-
    SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-
    SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-
    SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-
    AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-
    SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-
    SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-
    SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-
    SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA';
    ssl_prefer_server_ciphers on;
    ssl_dhparam /etc/n

    ginx/dhparams.pem;

    index index.html index.htm index.php;

    charset utf-8;

    # FORGE CONFIG (DOT NOT REMOVE!)
    include forge-conf/api.symaps.com/server/*;

    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; }

    access_log off;
    error_log  /var/log/nginx/api.symaps.com-error.log error;

    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }

    location ~ /\.ht {
        deny all;
    }
}

# FORGE CONFIG (DOT NOT REMOVE!)
include forge-conf/api.symaps.com/after/*;

Any ideas?

Thanks in advance.

Ad

Answer

Did you install the website under "default" or did you already set up the intended domain name in Forge? The issue that you describe could be caused by this. If so, either install it under the default directory (unadvisable, as you will have to edit your NGINX configuration, if you would want to enable SSL), or set up your DNS.

Ad
source: stackoverflow.com
Ad