I am new to nginx, I have configured my consul with nginx.

It's working but I have few doubts in my configuration.

here is my configuration

upstream consul {

server {
  listen 80 default_server;
  server_name localhost;

  location / {
    proxy_pass http://consul;

this is working fine if hit http://localhost, in my machine I am able to see consul UI.

But If I change my location to /consul, it is giving 404.

and what is the use of server name, if I change it to server_name mylocalserver;

I think I should be able to run my gttp request on this address http://mylocalserver. but that is also not working.

  • 1
    if you change your location to /consul, it does pass /consul to the backend also, which consul has no clue about unless you did configure it for that endpoint.
    – Tensibai
    Commented Apr 16, 2018 at 10:00

1 Answer 1

  1. You need to add a host entry of mylocalserver in the host file against, like mylocalserver.

  2. For /consul, there should be a /consul endpoint in your code to serve your request.

As per your configuration, your http://localhost will be served because you have set proxypass for "/"(all). It will send all requests to the application/server and will be served.

  • location means whatever I provide that should serve me the request on that location whatever I provide / or /consul (both should work).In both case it should go through this IP Commented Apr 11, 2018 at 9:59
  • You are right, with your configuration your all requests will be served but have you configured 'consul' directory in config.json ? can you show me your consul config file ?
    – BDShah1994
    Commented Apr 16, 2018 at 13:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.