server {
    listen 80;
    listen [::]:80;
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    ssl_certificate /etc/ssl/certs/nginx-cert.crt;
    ssl_certificate_key /etc/ssl/private/nginx-cert.key;

    # Increase the allowed body size from 1MB to 10MB, this ensures
    # large actions such as printing a PDF will always work.
    client_max_body_size 10M;

    location / {
        # Increase the request timeout from 1 minute to 10 minutes,
        # this is required for the self-flashing feature.
        proxy_read_timeout 600s;
        proxy_pass http://127.0.0.1:8069;
    }

    # If the iot_drivers module fails to start, the user will be sent to the
    # database selector. Instead of this we will show them the 502 error page
    # (IoT box is down) as it is more appropriate.
    location /web/database/selector {
        return 301 /502.html;
    }

    error_page 502 /502.html;
    location /502.html {
        root /var/www/html;
    }

    # Expose the /var/log/ folder directly via nginx, so that
    # it remains accessible even if Odoo is failing to start.
    location /odoo-logs {
        alias /var/log/;
        autoindex on;
    }
}
