Nignx404 Error

Asked 2 years ago, Updated 2 years ago, 68 views

I have a static page in CentOS 7 and Nginx (1.14.0).
index.html located directly below root is loaded, but no files beyond the subdirectory are loaded.

Specifically, when you access the domain .com, it appears normally, but when you access the domain .com/about, you get nginx 404 errors.

How do I load files from the subdirectory?
I would appreciate it if you could let me know.

nginx.conf is configured as follows:

usernginx;
worker_processes1;
pid/var/run/nginx.pid;

events {
    worker_connections1024;
}
US>http{
    include/etc/nginx/mime.types;
    default_type application/octet-stream;

    root/var/www/html;

    log_format main'$remote_addr-$remote_user[$time_local]"$request"'
                      '$status$body_bytes_sent"$http_refer"'
                      '''$http_user_agent''''$http_x_forwarded_for";

    access_log/var/log/nginx/access.log main;
    error_log/var/log/nginx/error.log debug;

    sendfile on;

    keepalive_timeout65;

    # Configuring for Top Domains    
    include/etc/nginx/conf.d/top.conf;

    # Configuring for Subdomains
    include /etc/nginx/conf.d/subdomain name.conf;

The top domain configuration top.conf is set as follows:

server{
    listen80; 
    server_name domain.com;
    charset UTF-8;

    location / {
      root/var/www/html;
      index index.html index.html index.php;
    }

    error_page500502503504/50x.html;

    location=/50x.html{
        root/usr/share/nginx/html;
    }

    location~\.php${
        root/var/www/html;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME$ document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

Configuring Subdomain Name.conf for Subdomains

 error_log/var/www/ directory name for subdomain /current/log/nginx.error.log;
access_log/var/www/subdomain directory name/current/log/nginx.access.log;

client_max_body_size2G;
upstream app_server{
  # Path to socket of cooperating unicorn
  server unix: /var/www/ directory name for subdomain /current/tmp/sockets/.unicorn.sock;
}

server{
  listen443 ssl;
  server_name subdomain name.com;
  keepalive_timeout5;
  root/var/www/ directory name for subdomain /current/public;

try_files$uri/index.html$uri.html$uri@app;
  location@app{
    # HTTP heads
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_redirect off;
    # proxy_pass http://127.0.0.1:3000;
    proxy_pass http://app_server;
  }

  error_page500502503504/500.html;
  location=/500.html{
    root/var/www/ directory name for subdomain /current/public;
  }
}

nginx

2022-09-30 18:02

1 Answers

We decided to rebuild the server from scratch.


2022-09-30 18:02

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.