Score:0

How to force HTTP status code to 404 with custom redirected 404 error page?

kp flag
Tim

I have setup a custom 404 error page to site on nginx setup.

I have this:

error_page 404 = @ext_404;

location @ext_404 {
    proxy_pass https://www.xexe.com;
    rewrite .* /en-en/test/250/ break;

    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host www.xexe.com;
    proxy_set_header X-NginX-Proxy true;
    proxy_redirect off;
    proxy_connect_timeout 1;
    proxy_intercept_errors off;
    expires 30;
}

The solution works as the error page is rendered and the URL on the browser is still the same, but the problem is with the HTTP status code which is 200. How do I force it to be 404? Or is there some other solution to this problem?

My main goal is to get a custom 404 error page from CMS so that users can modify it by them selfs.

Tim avatar
kp flag
Tim
Is the only way to archive this to modify the response status code from www.xexe.com/en-en/test/250/ to be 404? Do nginx offer some way to over-write proxy pass HTTP status code?
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.