Answer the question
In order to leave comments, you need to log in
How to write a config for a custom error_page page in nginx?
Hello everyone
I have a custom error_page page:
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel='stylesheet' type='text/css' href="../static/css/fonts.css">
<link rel='stylesheet' type='text/css' href="../static/css/styles.css">
</head>
<body>
<div class="top">
<img src="../static/images/logo.png" width="250" height="60" alt="logo">
</div>
<div class="error">Thres is internal server error. Please write us</div>
<div class="footer">
</div>
</div>
</body
</html>
server {
listen 80;
server_name awsome_domain;
recursive_error_pages on;
access_log /var/log/nginx/awsome_domain.log;
error_log /var/log/nginx/awsome_domain.log;
error_page 500 501 502 503 504 /50x.html;
location /50x.html {
root /var/www/awsome_domain/;
}
location / {
proxy_pass http://127.0.0.1:88888/;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Answer the question
In order to leave comments, you need to log in
everything turned out to be simple. it was necessary to register the root directory in the root :(. it is not entirely clear why he did not take it from the location
This is how it should work:
...
error_page 500 501 502 503 504 = @customerror;
location @customerror {
root /var/www/awsome_domain/;
try_files $uri /50x.html = 503;
#internal;
}
...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question