Articles > Odoo — Down for maintenance

Odoo — Down for maintenance

Give your users an explanation about what’s going on

Written by
Holden Rehg
Posted on
March 9, 2019

For every Odoo instance I configure, I add a Down For Maintenence page that displays when any 50x HTTP error occurs. This gives more information than a generic error page from the web server. That error page can really scare people when they don’t know what’s going on behind the scenes.

The web server (Nginx)

I’m using Nginx in this example, but it’s possible via any web server you are using. You can quickly install nginx on linux via sudo apt install nginx .

Here is an example of a very simple virtual host file located at /etc/nginx/sites-enabled/my.website.com.conf on our server:

server {
    listen 80;
    server_name my.website.com;
    client_max_body_size 128M;

    location / {
        proxy_pass http://localhost:20102;
    }

    location /longpolling/ {
        proxy_pass http://localhost:20103;
    }

    location ~ /[a-zA-Z0-9_-]*/static/ {
        proxy_pass http://localhost:20102;
    }

    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /usr/share/nginx/html;
        internal;
    }
}
        

You’ll notice that we do not have https configured because it’s listening on port 80, we are using a domain name of my.website.com , and we are assuming that there is an Odoo instance running on the server with an xmlrpcport of 20102 and a longpolling_port of 20103.

Below those common configurations is where we are setting up our Down For Maintenence HTML page.

error_page 500 502 503 504 /50x.html;
location = /50x.html {
    root /usr/share/nginx/html;
    internal;
}
        

This says that any time a 500, 502, 503, or 504 error occurs, show the user the HTML page located at /usr/share/nginx/html/50x.html .

The HTML

Now let’s check out the HTML. This really can be anything you’d like, but as a simple example, I’m using a popular gist available that I just slightly modified.

<!doctype html>
<head>
    <title>Site Maintenance</title>
    <style>
        body { text-align: center; padding: 150px; }
        h1 { font-size: 50px; }
        body { font: 20px Helvetica, sans-serif; color: #333; }
        article { display: block; text-align: left; width: 650px; margin: 0 auto; }
        a { color: #dc8100; text-decoration: none; }
        a:hover { color: #333; text-decoration: none; }</style>
</head>
<article>
    <h1>We will be back soon!</h1>
    <div>
        <p>
            Sorry for the inconvienence but we are performing some maintenence
            right now. Please <a href="mailto:myemail@gmail.com">contact us</a>
            if you need something, otherwise we will be back online shortly!
        </p>
        <p>- The Team</p>
    </div>
</article>
        

Keep things simple to start. A short paragraph that explains that there’s something going on and that we are working on it. If anyone needs to reach out, they can send an email to us.

End result

You can test it out by taking down your Odoo instance. Depending on how your Odoo instance is configured, you may run a sudo service odoo stop or if you happen to be using Docker (which I recommend) then you may run a docker stop {my_container} or docker-compose stop .

Either way, once the instance is down then you can navigate to your URL. In the example, that would be http://my.website.com.

You’ll see your HTML page:

Thanks For Reading

I appreciate you taking the time to read any of my articles. I hope it has helped you out in some way. If you're looking for more ramblings, take a look at theentire catalog of articles I've written. Give me a follow on Twitter or Github to see what else I've got going on. Feel free to reach out if you want to talk!

docker
odoo
open source
erp
web development
Share:

Holden Rehg, Author

Posted March 9, 2019