Answer the question
In order to leave comments, you need to log in
How to correctly create location when using proxy_pass?
Hi. I have the following nginx config:
server {
listen 80;
# Grafana
location / {
add_header Access-Control-Allow-Origin "*";
proxy_pass http://127.0.0.1:3000/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
# Graphite
location /graphite/ {
#add_header Access-Control-Allow-Origin "*";
proxy_pass http://127.0.0.1:8000/;
#proxy_set_header Host $host;
#proxy_set_header X-Real-IP $remote_addr;
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
172.16.0.86 - - [11/Jan/2016:17:07:07 +0300] "GET /graphite/ HTTP/1.1" 200 542 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36"
172.16.0.86 - - [11/Jan/2016:17:07:07 +0300] "GET /browser/header/ HTTP/1.1" 404 1251 "http://192.168.42.30/graphite/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36"
172.16.0.86 - - [11/Jan/2016:17:07:07 +0300] "GET /composer/? HTTP/1.1" 404 1251 "http://192.168.42.30/graphite/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36"
Answer the question
In order to leave comments, you need to log in
In general, the problem is not so much in nginx, but in the apps themselves. Grafana has a root_url directive : Grafite has
something similar, but it was not possible to build a working version right away. Therefore, I left it as it is and the nginx config looks like this:
server {
listen 80;
# Grafana
location /grafana {
rewrite ^/grafana/(.*) /$1 break;
proxy_pass http://127.0.0.1:3000;
}
# Graphite
location / {
proxy_pass http://127.0.0.1:8000;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question