I am a Nginx noob. I am trying to execute the location block which matches the general condition in all the cases but use the /account condition for for url matching that. So for request www.abc.com, www.abc.com/var1, www.abc.com/var2/var3 I want the first block to be execute but for request like www.abc.com/account, wwww.abc.com/account/, www.abc.com/account/123 block 2 should execute.

I have the following config for the nginx -

events {}

user nginx;

http {

        include mime.types;
        server {
        listen 80;
        server_name _;
        root /var/www;
        access_log   /var/log/nginx/access.log;
        error_log    /var/log/nginx/error.log error;

        location / {
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        location = /account/1000 {
        return 307 hi;


Right now the whichever block I write first gets executed. Any help on this will go a long way.

0 Answers