S
S
Stanislav Pochepko2017-03-15 20:25:42
Nginx
Stanislav Pochepko, 2017-03-15 20:25:42

How to make custom message with 404 response in nginx?

There is some config

server {
    listen 443 ssl;
    listen [::]:443 ssl;

    ...

    root /var/www/symfony/web;

    ...

    location / {
        # try to serve file directly, fallback to app.php
        try_files $uri /app.php$is_args$args;
        if ($allowed_country = no){
            return 404; # Здесь происходит ответ. Необходимо кастомное сообщение тип "Нет доступа для вашего региона"
        }

     ...

    }

It is necessary to display a message with a 404 response. Is it possible?
Or how then to organize it correctly? I don't want to use custom error pages. (error_page) Need to handle a single case

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
ky0, 2017-03-15
@DJZT

return 404 message;
"Starting from version 0.8.42, you can set either the redirect URL (for codes 301, 302, 303, and 307) or the response body text (for other codes)."
nginx.org/ru/docs/http/ngx_http_rewrite_module.htm...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question