1

I am using NGINX as a reverse proxy for a Grafana server which is connected to Elasticsearch. Elasticsearch is not publicly accessible (currently) but I would like to have a link from Grafana to a specific document.

Currently, I have the following block:

 location / {
            proxy_pass http://localhost:3000;
            ...
 }

And I would like to add another URL that would proxy from /id/1234 to the url http://localhost:9200/myindex/_doc/1234. But I only want it to be if the id is an integer.

How would I do that?

1
  • location ~ ^/id/[0-9]+ ? Commented Jun 12, 2019 at 14:17

1 Answer 1

1

For any integer id you will need to capture it using a regular expression location and pass it to the proxy_pass directive as a variable.

For example:

location ~ /id/([0-9]+)$ {
    proxy_pass http://localhost:9200/myindex/_doc/$1;
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.