nginx custom maintenance 503 page

I have a nginx with a custom 503.

error_page 503 @maintenance;

location @maintenance {
    root   /usr/share/nginx/html/custom/503;
    rewrite ^(.*)$ /index.html break;
}

location  /503-static/ {
    root /usr/share/nginx/html/custom/;
}

My /503/index.html is my custom maintenance page witch includes a nice CSS and photos:

<link rel="stylesheet" type="text/css" href="https://www.mydomain.tld/503-static/maintenance.css">

All these is working fine.

Problem is that I would like to replace css link with a relative one like 503-static/maintenance.css.

In the case when user requests: www.mydomain.tld custom html will be loaded and maintenance.css with relative path will load as well

But: in the case when user requests: www.mydomain.tld/a/b/c/bla.html, my custom 503 index html will be loaded fine but relative link for css will be $document_root/a/b/c/503-static/maintenance.css .... and will not display

My question is: using relative link path for css file ... how to cope with different $uri? Any help with a rewrite ?

Thank you

Answers


Just strip the protocol and domain, keep the leading slash. Relative paths are a very bad fit for this scenario. Absolute work perfectly.


Need Your Help

Syntax where let (constant) behaves like a function. Can you explain?

ios swift function constants alamofire

I came acros this syntax while trying to overwrite a file in Swift, but I can't understand it, since it seems that the constant behaves like a function (I'm using Alamofire for networking):

Adding a gallery to lightbox1

javascript lightbox lightbox2

I'm trying to add an image gallery function to the original lightbox -- http://lokeshdhakar.com/projects/lightbox/. I'm utilizing it in an addon to ContentFlow, and want the user to be able to nav...