nginx reverse proxy

I am using nginx to reverse proxy to some backend service (serviceX).

location /data {
   ...
  # rewrite ...
  proxy_pass http://backend
}

when client request for http://proxy/data/status, it should direct to http://backend/status

it took me really a long time to figure out (have tried with various rewrites), turns out the trick is to tell nginx when proxy_pass (http), it should pass the uri with a /, something like

location /data/ {
   proxy_pass http://backend/
}
Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s