登录

在 linux 中安装 lnmp Nginx 的配置 问题

Nginx 下有很多域名网站 当域名解析到服务器上的 时候 访问时 报错了 403 或者404

因为服务器还没有配置 域名, 在直接访问服务器的ip 时 也是报错的

404 Not Found

nginx/1.4.4

或者

403 Not Found

nginx/1.4.4
这样的错误 我想修改一下 这样报错信息! 对 是 域名解析到服务器了 而服务器 没有做该域名的配置; 报了403错误 或者 访问服务器 ip 地址

nginx.conf 如下 该怎么配置自定义的 403 和 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; }
# Linux
PHPzhongPHPzhong2073 天前501 次浏览

全部回复(1) 我要回复

  • PHPzhong

    PHPzhong2017-05-16 17:25:16

    http://nginx.org/en/docs/http/ngx_http_core_module.html#error_page
    自定义404页面,比如交给PHP处理:

    error_page 404 = /404.php;
    

    403类似.

    回复
    0
  • 取消回复发送