6

I'm trying to move to nginx from apache but one of the features I most use in apache are the ssi includes. I'm testing how nginx deal with ssi but I'm having some problems...

If an include virtual file doesn't exist I'm getting a 404 page embeded, not even the [an error has occurred] message. With apache ssi, if the file doesn't exist an error is shown as comment.

The other point is, with apache SSIErrorMsg directive I can set at server config level the error text but I couldn't find this in nginx, just the <!--# config errmsg="custom error" --> inside the html. I coudn't see a directive like SSIErrorMsg in nginx documentation

nginx 404 ssi error :

<html>
<head>
  <title>simple</title>
</head>
<body>
<html>
<head><title>404 Not Found</title></head>
<body bgcolor="white">
<center><h1>404 Not Found</h1></center>
<hr><center>nginx/1.6.2</center>
</body>
</html>
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
</body>
</html>

but in apache:

<html>
<head>
  <title>simple</title>
</head>
<body>
<!-- Error -->
</body>
</html>

The error message only appears in nginx when for instance I write a ssi include with some typo like <!--#include virtualll="example.html"-->

Is there a way to show an error instead of embedding the 404 file in case of not found?

This is the nginx server config:

server {
  listen  80;
  server_name demo.localhost;

  ssi on;
  ssi_silent_errors off;

  location / {
    root  /var/www/demoweb;
  }
}

If I set ssi_silent_errors off; nothing is shown but I want something like <!--Error--> as apache does

gabifm
  • 61
  • 1
  • 6

0 Answers0