Home  >  Q&A  >  body text

Installing lnmp Nginx configuration issues in linux

There are many domain name websites under Nginx. When the domain name is resolved to the server, an error 403 or 404 is reported when accessing

Because the server has not configured a domain name, an error is also reported when directly accessing the server's IP

404 Not Found

nginx/1.4.4

or

403 Not Found

nginx/1.4.4
I want to correct such an error and report an error message like this! Yes, the domain name has been resolved to the server, but the server has not configured the domain name; a 403 error is reported or the server ip address is accessed

nginx.conf is as follows. How to configure custom 403 and 404


user www www; worker_processes 1; error_log /alidata/log/nginx/error.log crit; pid /alidata/server/nginx/logs/nginx.pid; #Specifies the value for maximum file descriptors that can be opened by this process. worker_rlimit_nofile 65535; events { use epoll; worker_connections 65535; } http { include mime.types; default_type application/octet-stream; #charset gb2312; server_names_hash_bucket_size 128; client_header_buffer_size 32k; large_client_header_buffers 4 32k; client_max_body_size 8m; sendfile on; tcp_nopush on; keepalive_timeout 60; tcp_nodelay on; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; fastcgi_buffer_size 64k; fastcgi_buffers 4 64k; fastcgi_busy_buffers_size 128k; fastcgi_temp_file_write_size 128k; fastcgi_intercept_errors on; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.0; gzip_comp_level 2; gzip_types text/plain application/x-javascript text/css application/xml; gzip_vary on; #limit_zone crawler $binary_remote_addr 10m; log_format '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; include /alidata/server/nginx/conf/vhosts/*.conf; }
PHPzPHPz2713 days ago759

reply all(1)I'll reply

  • PHPz

    PHPz2017-05-16 17:25:16

    http://nginx.org/en/docs/http/ngx_http_core_module.html#error_page
    Customize the 404 page, such as handing it to PHP:

    error_page 404 = /404.php;
    

    403 is similar.

    reply
    0
  • Cancelreply