Skip to content

Instantly share code, notes, and snippets.

@hlassiege
Created June 1, 2014 16:55
Show Gist options
  • Save hlassiege/179866de70c3d8d992ab to your computer and use it in GitHub Desktop.
Save hlassiege/179866de70c3d8d992ab to your computer and use it in GitHub Desktop.
Nginx configuration for kibana
server {
listen 80;
server_name A.com;
root /var/www/kibana;
# Set image format types to expire in a very long time
location ~* ^.+\.(jpg|jpeg|gif|png|ico)$ {
access_log off;
expires max;
}
# Set css and js to expire in a very long time
location ~* ^.+\.(css|js)$ {
access_log off;
expires max;
}
# Catchall for everything else
location / {
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/sites-available/kibana.htpasswd;
root /var/www/kibana;
index index.html;
expires 5d;
try_files $uri/ $uri;
if (-f $request_filename) {
break;
}
# For CORS Ajax
proxy_pass_header Access-Control-Allow-Origin;
proxy_pass_header Access-Control-Allow-Methods;
proxy_hide_header Access-Control-Allow-Headers;
add_header Access-Control-Allow-Headers 'X-Requested-With, Content-Type';
add_header Access-Control-Allow-Credentials true;
}
location ~ ^/es/(.*/_search)$ {
rewrite ^/es/(.*/_search)$ /$1 break;
limit_except POST {
deny all;
}
proxy_pass http://B.com:80;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
# For CORS Ajax
proxy_pass_header Access-Control-Allow-Origin;
proxy_pass_header Access-Control-Allow-Methods;
proxy_hide_header Access-Control-Allow-Headers;
add_header Access-Control-Allow-Headers 'X-Requested-With, Content-Type';
add_header Access-Control-Allow-Credentials true;
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/sites-available/kibana.htpasswd;
}
location /es/kibana-int/ {
rewrite ^/es/(kibana-int/.*)$ /$1 break;
proxy_pass http://B.com:80;
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/sites-available/kibana.htpasswd;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
# For CORS Ajax
proxy_pass_header Access-Control-Allow-Origin;
proxy_pass_header Access-Control-Allow-Methods;
proxy_hide_header Access-Control-Allow-Headers;
add_header Access-Control-Allow-Headers 'X-Requested-With, Content-Type';
add_header Access-Control-Allow-Credentials true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment