0
votes

I have installed Nginx 1.12.2 on CentOS 7. I have an extremely simple nginx config and it is not working at all. I have setup several nginx instances on Ubuntu in the past without any issue I wonder if there is something to do with CentOS.

I have double-checked that the "root" directory exists and the files also exist with proper permissions. But I am getting 404 error. Also for debugging purpose, I tried to put "return 200 $uri" in the location block and it seems to be returning me the proper URI but try_files doesn't work

  • /var/www/mydomain/public/test.html exists with proper permissions
  • For debugging when I put "return 200 $uri" it shows up when I hit the domain
  • Hitting mydomain.com/test.html gives 404
server {
    listen 80;

    root /var/www/mydomain/public;
    index index.html index.htm;

    server_name mydomain.com;

    location / {
#       return 200 "$uri";
        try_files $uri $uri/;
    }
}
1

1 Answers

0
votes

Few things:

  • Check your NGINX error log at /var/log/nginx/error.log, you will likely see what file is being accessed and make conclusions from that
  • Be aware of the presence of /etc/nginx/conf.d/default.conf, which is shipped with the package. It has default server, which is what NGINX will use when no domain has matched, however it's a sample file rather than a real config. I tend to just echo > /etc/nginx/conf.d/default.conf, to "remove it" in a safe way. (If you just remove the file, then package update will restore it, but if you nullify it like I do, then package upgrades won't touch it).