I would like to create a location which catches both http://example.com and http://example.com/ and another location which catches everything else. The first one will serve static html and the other one is for the api and other stuff. I've tried with this:
location ~ /?$ {
    root /var/www/prod/client/www;
}
location ~ /.+ {
    # https://stackoverflow.com/questions/21662940/nginx-proxy-pass-cannot-have-uri-part-in-location
    rewrite ^/(.*) /$1 break;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_set_header X-NginX-Proxy true;
    proxy_connect_timeout       1s;
    proxy_send_timeout          30s;
    proxy_read_timeout          300s;
    send_timeout                300s;
    proxy_redirect off;
    proxy_pass http://backendPro;
}
But does not work. I've tried with many options in first location, but when it matches first then second is not matching and vice-versa:
location / {
location ~ \/?$ {
location ~ ^/?$ {
 
    