Answer the question
In order to leave comments, you need to log in
How to proxy for a specific location in Nginx?
Hello,
How can I make Nginx proxy for a specific location ? I need Grafana to open when accessing the https://corp.domain.com domain , and Prometheus to open when accessing the https://corp.domain.com/prom/ link .
Now I have this config, it does not work :
server {
server_name corp.domain.com;
............ Тут часть от Let's Encrypt сертификата ............
location / {
proxy_pass http://localhost:3000;
gzip off;
proxy_buffers 8 32k;
proxy_buffer_size 64k;
proxy_request_buffering off;
proxy_read_timeout 300;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Ssl on;
proxy_set_header X-Frame-Options SAMEORIGIN;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location /prom {
proxy_pass http://localhost:9090/;
}
............ Тут тоже часть от Let's Encrypt сертификата ..... например переадресация c http на https.......
}
Answer the question
In order to leave comments, you need to log in
nginx.org/ru/docs/http/request_processing.html
you have two hosts - corp.host and host
so configure them
why do you put host settings in corp.host ?
https://www.8host.com/blog/nastrojka-virtualnyx-xo...
Well, nginx redirects the request as it is, and it seems that prometheus decides that this is an invalid page and through a 302 redirect redirects to the main domain where the grafana is located, because of this it seems to you that it does not work. You need to specify the host in the prometheus settings as https://corp.domain.com/prom/ or cut down the headers via proxy_pass_request_headers off and manually specify the path there, but I think it won’t work anyway, when you click on any link, it will toss into the graphana.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question