---
title: "Nginx1.4+设置默认404页面"
author: "sw1982"
date: "2014-03-04T11:39:22Z"
tags: []
categories: ["Web前端"]
slug: "nginx1-4-404"
draft: false
lastmod: "2014-03-04T11:39:22Z"
id: 2025333
url: "https://sw1982.iteye.com/blog/2025333"
---

之前参考了不少文件，配置均不生效。

 

过程(ubuntu)：

1.到nginx安装目录新建一个404.html      /usr/share/nginx/html

 

2.到各server节点下新增404处理逻辑

vim /etc/nginx/sites-enabled/default

```
server {
    listen 80 ;
    server_name m.xx.com;
    root /var/www/m;
    index m.html;
    error_page 404  /404.html;
    location = /404.html {
       root /usr/share/nginx/html;
    }
}
```

 

 

误解一， 要vim /etc/nginx/nginx.conf ，在http块加fastcgi\_intercept\_errors参数 

```
http {
    #fastcgi_intercept_errors on;
```

 

This module allows Nginx to interact with FastCGI processes and control what parameters are passed to the process.

 

这个模块仅对fastcgi生效，yes就是说纯html的跳转，其实不加这个参数即可。