3

I am configuring a nginx revser proxy. The result should be when user type http://10.21.169.13/mini, then the request should be proxy_pass to 192.168.1.56:5000. Here is the nginx config:

server {
        listen 80;
        server_name 10.21.169.13;

        location = /mini {
                proxy_pass http://192.168.1.65:5000;
                include /etc/nginx/proxy_params;
        }
}

The above location block never worked with http://10.21.169.13/mini. The only location block worked is:

server {
        listen 80;
        server_name 10.21.169.13;

        location  / {
                proxy_pass http://192.168.1.65:5000;
                include /etc/nginx/proxy_params;
        }
}

But the above config also match http://10.21.169.13 request which is too board.

What location block will only match 'http://10.21.169.13/mini` and no more?

UPDATE: tried and failed with the following:

 location  /mini {
                    proxy_pass http://192.168.1.65:5000;
                    include /etc/nginx/proxy_params;
            }

location  /mini/ {
                    proxy_pass http://192.168.1.65:5000;
                    include /etc/nginx/proxy_params;
            }

The error is request not found.

user938363
  • 9,990
  • 38
  • 137
  • 303

1 Answers1

2

Try this out:

server {
    listen 80;
  server_name 10.21.169.13;

  # root /usr/share/nginx/html;
    # index index.html index.htm;

  location  / {
        # add something here to handle the root
        # try_files $uri $uri/ /index.html;
    }

  location  /mini {
    proxy_pass http://192.168.1.65:5000;
    include /etc/nginx/proxy_params;
    }

}

Let me know if that works for you.

Ray Hunter
  • 15,137
  • 5
  • 53
  • 51
  • `srayhunter`, there is 404 Not Found error with the conf above. – user938363 Mar 21 '17 at 01:29
  • @user938363 you will need to configure the commented out code for your current setup. So if you have a root directory you will need to specify that and then you can uncomment the **try_files** line. – Ray Hunter Mar 21 '17 at 16:03
  • There is no root. The nginx provides web access for OctoPrint which is a 3D printer management software. – user938363 Mar 22 '17 at 02:43
  • Im not sure what you should have there, but you might need to setup a root so that the `/mini` is handled properly. – Ray Hunter Mar 22 '17 at 16:51