Smilie's avatar

nginx 404

Hi, After working on my app locally, I deployed it to a test environment. Unfortunately I seem to be hitting a 404 no matter what I do. I use nginx with php-fpm.

The error from my log:

2020/05/17 11:21:02 [error] 25944#25944: *33 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 87.61.93.61, server: sbt.core.hon.team, request: "POST /user/auth HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.4-fpm.sock:", host: "sbt.core.hon.team"

My nginx config:

server {
    server_name sbt.core.hon.team;
    root /var/www/test/sbt.core.hon.team/current/public;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

	access_log /var/www/test/sbt.core.hon.team/logs/access.log;
	error_log /var/www/test/sbt.core.hon.team/logs/error.log;

    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:/run/php/php7.4-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }

    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/sbt.core.hon.team/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/sbt.core.hon.team/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}server {
    if ($host = sbt.core.hon.team) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    listen 80;
	listen [::]:80;
    server_name sbt.core.hon.team;
    return 404; # managed by Certbot


}

I guess it has to do with

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

This parameter was initially:

fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;

However this produced the same error. I was mainly inspired by https://laravel.com/docs/7.x/deployment#nginx

I'm not sure where to go from here

0 likes
0 replies

Please or to participate in this conversation.