您的位置:首页 > 运维架构 > Nginx

nginx 定义502 404 错误提示页面

2009-06-05 15:45 661 查看

nginx 定义502 404 错误提示页面

[align=left]nginx 与后端 web server 是分开的,二台服务器[/align]
[align=left] [/align]
[align=left]192.168.1.11 Nginx[/align]
[align=left]192.168.1.12 Web server[/align]
[align=left] [/align]
[align=left]定义nginx 404 502错误提示页面,直接配置nginx 502错误,找了很多资料,最终没能实现。下面用另一个方法实现.[/align]
[align=left] [/align]

方法一、

[align=left]在nginx.conf配置文件里加上以下红色代码[/align]
[align=left] [/align]

erver
{
listen 80;
server_name www.tt.com;

location / {
proxy_pass http://week; proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
if (!-f $request_filename) {
proxy_pass http://127.0.0.1:8888; }
}
17.0.0.1:8888配置如下

erver
{
listen 8888;
server_name www.tt.com;
location / {
root /root;
index index.html;
error_page 500 502 404 /404.html;
}

}
需要维护的时候,只需要重启nginx服务。

kill -HUP 'cat logs/nginx.pid'

方法二、

单独创建一个testnginx.conf文件

#user nobody;
worker_processes 1;
pid logs/nginx.pid;

events {
use epoll;
worker_connections 50000;
}

http {
include mime.types;
default_type application/octet-stream;
sendfile on;
server
{
listen 80;
server_name www.tt.com;
location / {
root /root;
index index.html;
error_page 500 502 404 /404.html;
}

}
}
维护时只需把nginx停止,从新启用新的配置文件

killall -9 nginx
nginx -c ../conf/testnginx.conf本文出自 “网海过客” 博客,请务必保留此出处http://cqfish.blog.51cto.com/622299/163238
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: