Using nginx as a frontend to our modperl apache2 servers.

We have a soft 404 problem at Google Search Console.

The problem is that we have many pages expiring all the time, once they expire we add a noindex robots tag immediately, show a "no longer available" screen to the viewer but are unable to send a 404 header to Google as nginx sends the header and the header is a 200 as the page is served ok in its eyes.

How can I tell apache to notify nginx to send a 404 header?

1 Answer 1


Use error_page directive and add this code:

  server {
      error_page 404 /404.html;
      location = /404.html {
        root   /usr/share/nginx/html;
        add_header Cache-Control "no-cache" always;
  • How would we get nginx to send the 404 after receiving the 200 from apache? Commented May 17, 2016 at 16:47
  • add that in error page because it adds another header.
    – Josip Ivic
    Commented May 18, 2016 at 7:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.