Reputation: 71
TL;DR I'm not talking about HTTP errors but about internal connection refused error
Hi!
I'm developping a website with Nginx and Django for backend. Nginx is used as a reverse proxy from another server. I'm also using Cloudflare. Here is my site conf :
server {
listen 80;
server_name my.website.fr;
proxy_intercept_errors on;
location / {
proxy_pass http://192.168.0.128:9001;
}
error_page 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 420 422 423 424 426 428 429 431 444 449 450 451 500 501 502 503 504 505 506 507 508 509 510 511 /index.html;
location /index.html {
root /var/www/maintenance;
internal;
}
}
When my backend server (192.168.0.128) is up and running everything is working. But, when my Django service is down, I got a connection refused (111) error in my nginx logs and a Cloudflare's error page 502 bad gateway.
Is there a way to catch those kind of "low level" network error and show my maintenance page ?
Thanks!
Upvotes: 4
Views: 5808
Reputation: 71
I fixed my issue. My previous conf only handles "/index.html" connections for the errors. Here's my new config:
server {
listen 80;
server_name test.tcoolmax.fr;
proxy_intercept_errors on;
location /maintenance {
proxy_pass http://localhost:8080;
}
location / {
proxy_pass http://192.168.0.128:9001;
}
error_page 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 420 422 423 424 426 428 429 431 444 449 450 451 500 501 502 503 504 505 506 507 508 509 510 511 maintenance;
}
Upvotes: 2