The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
grafana/devenv/frontend-service/nginx.conf

93 lines
2.3 KiB

###
# Instance
###
upstream backend {
server backend:3000;
}
upstream frontend {
server frontend-service:3000;
}
server {
listen 80;
server_name _;
# Special‐case POST /login to backend, GET to frontend
location = /login {
proxy_set_header Host $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;
if ($request_method = POST) {
proxy_pass http://backend;
break;
}
if ($request_method = GET) {
proxy_pass http://frontend;
break;
}
return 405;
}
# API calls go to the backend
# Cheat with app plugin paths and route them to the backend. These should come from
# the Plugin CDN
location ~ ^/(api|apis|bootdata|public\/plugins\/grafana\-\w+\-app) {
proxy_pass http://backend;
proxy_set_header Host $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 Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
# Everything else to the frontend
location / {
proxy_pass http://frontend;
proxy_set_header Host $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;
}
}
###
# CDN
###
map $request $loggable {
default 1;
"~^\x16\x03" 0;
}
server {
listen 81;
server_name localhost;
root /cdn;
# Enable directory listing
autoindex on;
autoindex_exact_size off;
autoindex_format html;
autoindex_localtime on;
add_header Cache-Control "no-cache, no-store, must-revalidate" always;
add_header Pragma "no-cache" always;
add_header Expires "0" always;
add_header Access-Control-Allow-Origin "*" always;
add_header Access-Control-Allow-Headers "X-Grafana-Device-Id" always;
# Suppress access log for malformed HTTPS requests (those starting with a TLS handshake)
access_log /var/log/nginx/access.log main if=$loggable;
# This serves paths like /grafana/12.1.0-88106/public/build/foo
location ~ ^/grafana[^/]*/[^/]+/(.*)$ {
alias /cdn/$1;
}
}