Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Post History

83%
+8 −0
Q&A Setting custom HTTP status code messages in nginx

I think it would be funny if my web application that is hosted using an nginx reverse proxy (proxy_pass) returned something like 200 Could Be Worse rather than 200 OK, when the page load was succes...

1 answer  ·  posted 8d ago by luap42‭  ·  last activity 3d ago by Ancepaid‭

Question http nginx
#1: Initial revision by user avatar luap42‭ · 2025-04-03T22:20:56Z (8 days ago)
Setting custom HTTP status code messages in nginx
I think it would be funny if my web application that is hosted using an nginx reverse proxy (proxy_pass) returned something like `200 Could Be Worse` rather than `200 OK`, when the page load was successful.

I know that there is a `return 200 "message";` command, but when I just add that to my site config file, the rest of the response is not returned but just the message portion. I tried adding a `\n` at the end, as I read somewhere, but it didn't change anything.

Also, a possible issue with this approach is that, as far as I can tell, it would *always* return "200 Could Be Worse", even if it should respond with something like 404 or 500.

I thought about adding an `error_page` rule, but if I add that for a 200 status code, nginx config validation fails with the following error message:

```
nginx: [emerg] value "200" must be between 300 and 599 in /etc/nginx/sites-enabled/[site-name]:8
nginx: configuration file /etc/nginx/nginx.conf test failed
```

So, how *do* I make my http status messages more fun in nginx?