how many hs can you find in:
q: right way to configure nginx filtering with proxypass i am using nginx to proxy pass to my wsgi app served with circus.
i want to allow the traffic to that app for some urls of the app only for some ip address.
for now it look like this:
server {
    listen   80;
    server_name  service.dev;
    access_log  /var/log/service.access.log;
    error_log  /var/log/service.error.log debug;

    location / {
        try_files $uri @proxy_to_app;
    }

    location @proxy_to_app {
        proxy_set_header host $http_host;
        proxy_redirect off;
        proxy_pass         http://127.0.0.1:9000/;
    }

    location /admin/ {
        allow 192.168.5.0/24;
        deny all;
    }
}

but it doesnt work. if i have the right, i get a 404 error instead of the proxy_pass.
do you know how i can do that without having to copy/paste the proxy_pass configuration each time?
thank you.

a: edit 2
as per vbarts comments, ive changed the entries in try_files to $uri @proxy_to_app. this avoids any confusion over the order of named locations (they must always come last). be advised that if the /admin/ directory exists locally, this will be used instead of the proxy.
edit
if you really want to use a named location to avoid duplicating proxy_pass for each location, you can use the following:
server {
    listen       80;
    server_name  service.dev;
    access_log   /var/log/service.access.log;
    error_log    /var/log/service.error.log debug;

    location / { 
        # catch all 
        try_files $uri @proxy_to_app;
    }   

    location /admin/ {
        # /admin/ only
        allow 192.168.5.0/24;
        deny  all;
        try_files $uri @proxy_to_app;
    }   

    location @proxy_to_app {
        proxy_set_header  host $http_host;
        proxy_redirect    off;
        proxy_pass        http://127.0.0.1:9000;
    }   
}

its a bit of a hack, try_files requires at least two parameters, in the first instance it will look for a local path with the same $uri (if you want to override with local files). in the second instance ive specified /dev/null as the second path; this will never be used.
original
try this configuration:
server {
    listen       80;
    server_name  service.dev;
    access_log   /var/log/service.access.log;
    error_log    /var/log/service.error.log debug;

    # proxy settings
    proxy_set_header   host $http_host;
    proxy_redirect     off;

    location / {
        # catch all
        proxy_pass     http://127.0.0.1:9000/;
    }

    location /admin/ {
        # /admin/ only
        allow 192.168.5.0/24;
        deny  all;
        proxy_pass     http://127.0.0.1:9000/;
    }
}

the location / block should only catch uris that are not matched subsequently in other location blocks.

user
The text includes 64 "h"s in total.
assistant