nginx catch all other locations than given

I have some locations on my server. I want to catch all other locations which users give via browser. How to to that? For example

 server {
     ...
     location /location1 {
              do something;
     }
     location /location2 {
              do something;
     }
     location /all_other_locations {
            return 301 http://www.google.de
     }

Solution 1:

nginx's locations are prefix based (except regexp ones), so location / matches all requests unless more specific one matches.

server {
    location / {
        # catch all unless more specific location match
    }

    location /location1 {
        # do something
    }

    location /location2 {
        # do domething
    }
}