i custom varnish 500 error page,but i found that it could not display chinese characters,
i tried deliver an error page from a static file, but it is not working User-friendly error pages from Varnish
i custom varnish 500 error page,but i found that it could not display chinese characters,
i tried deliver an error page from a static file, but it is not working User-friendly error pages from Varnish
The example you're pointing to manipulates the file contents with sprintf and strcat, which probably don't work well on UTF-8 (your file is in UTF-8 like the header states, right?). You might test your luck with a byte-based C function like memcpy, or use a utf-8 proof string copy/formatting function (never dealt with this stuff in C).
Could you describe it is not working in more detail?
below is the full part of Related in varnish.vcf
C{
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
}C
sub vcl_error {
set obj.http.Content-Type = "text/html; charset=utf-8";
set obj.http.Retry-After = "5";
if ((obj.status == 500 || obj.status == 503)&&client.ip !~ flnet){
C{
FILE *infile;
char *buffer;
char fname [50];
long numbytes;
sprintf(fname, "/var/www/html/%d.html", VRT_r_obj_status(sp));
infile = fopen(fname, "r");
if(infile == NULL)
return 1;
fseek(infile, 0L, SEEK_END);
numbytes = ftell(infile);
fseek(infile, 0L, SEEK_SET);
buffer = (char*)calloc(numbytes, sizeof(char));
fread(buffer, sizeof(char), numbytes, infile);
fclose(infile);
VRT_synth_page(sp, 0, buffer, "<!-- XID: ", VRT_r_req_xid(sp), " -->", vrt_magic_string_end);
free(buffer);
return 0;
}C
}