cancel
Showing results for 
Search instead for 
Did you mean: 

404 not found Nginx Magento 2

404 not found Nginx Magento 2

Hi Everyone ,

 

I faced an issue Nginx Configuration with Magento 2

 

Only home page working fine
All other pages are display 404 not fount error


OS Centos 6

/etc/nginx/conf.d.ssl.conf

 

server {
listen 443 ssl http2 ;
listen [::]:443 ssl http2;
server_name test.com;
root /home/test/public_html;
index index.php index.html index.htm;


ssl on;
#ssl_certificate /etc/nginx/ssl/server.crt;
#ssl_certificate_key /etc/nginx/ssl/server.key; 
ssl_certificate /home/test/ssl/certs/test_com_de3f4_5bcd1_1554013412_51e33ac7d469b307fd6c85a301cbfe02.crt;
ssl_certificate_key /home/test/ssl/keys/de3f4_5bcd1_138acd81f71b52d5feaff8c0c9c2d7ed.key; 
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers 'AES128+EECDH:AES128+EDH:!aNULL';
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 24h;
keepalive_timeout 300s;


location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/opt/cpanel/ea-php71/root/usr/var/run/php-fpm/b3957c85b90c6e85f15e09181fd6aa5744ef534b.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;

}

}


/etc/nginx/conf.d/magento.conf

upstream fastcgi_backend {
server unix:/opt/cpanel/ea-php71/root/usr/var/run/php-fpm/b3957c85b90c6e85f15e09181fd6aa5744ef534b.sock;
} 


server {
listen 80;
server_name test.com;
return 301 $scheme://test.com$request_uri;
}

server {
listen 80 reuseport;
server_name test.com;

set $MAGE_ROOT /home/test/public_html/magento2/project-community-edition;

set $MAGE_MODE production;
# set $MAGE_MODE default;
# set $MAGE_MODE production;

include /home/test/public_html/magento2/project-community-edition/nginx.conf.sample;
fastcgi_read_timeout 3000;

}

I have use the default nginx.conf.sample file


Any solution?

 

Thanks in Advance

4 REPLIES 4

Re: 404 not found Nginx Magento 2

Hi @Sumayah

 

Please add file name In your magento nginx config same as below:

# PHP entry point for main application
location ~ (index|get|static|report|404|503|testfile)\.php$ {
    try_files $uri =404;
    fastcgi_pass   fastcgi_backend;
    fastcgi_buffers 1024 4k;

    fastcgi_read_timeout 600s;
    fastcgi_connect_timeout 600s;

    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    include        fastcgi_params;
}

then Run below command:

service nginx restart
If you find my answer useful, Please click Kudos & Accept as Solution.

Thanks Smiley Happy

Re: 404 not found Nginx Magento 2

Hi @Geeta Modi
Its already there 

 

Please check the file here 

nginx.conf.sample

 

 

 

Re: 404 not found Nginx Magento 2

Hi @Sumayah

 

I think you have missed some index related configuration. So please check these link, I hope these are helpful for you.

 

If you find my answer useful, Please click Kudos & Accept as Solution.

Thanks Smiley Happy

Re: 404 not found Nginx Magento 2

I was able to compare a working site with a non working site.

There was extra cruft in the url values in core_config_data.

 

 

UPDATE core_config_data SET value = NULL WHERE path IN ('web/unsecure/base_static_url','web/unsecure/base_media_url','web/secure/base_static_url','web/secure/base_media_url');


All of these needed to be NULL.

web/unsecure/base_link_url | {{unsecure_base_url}} 
web/unsecure/base_media_url | {{unsecure_base_url}}pub/media/ 
web/unsecure/base_static_url | {{unsecure_base_url}}pub/static/
web/secure/base_link_url | {{secure_base_url}} 
web/secure/base_media_url | {{secure_base_url}}pub/media/ 
web/secure/base_static_url | {{secure_base_url}}pub/static/ 


Resolved it for me.