Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.7k views
in Technique[技术] by (71.8m points)

nginx如何配置直接返回400状态码?

现在有个需求,需要让nginx在某个端口下直接返回400状态码,请问如何实现?

例如现在要在1234端口直接返回400错误码,应该如何配置nginx?

server {
    listen 1234;
    location / {
    index =400; #这么配置不对
    }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
server {
    listen 1234;
    location / {
        return 400;
    }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...