Kibana dashboard couldn't connect with Nginx - nginx

Hi i'm trying to use Nginx as a reverse proxy for accessing a Kibana 4 dashboard. The location of the dashboard is not available in the latest kibana but it can be accessed using a URL.
Kibana and Nginx are running both locally and installed on a windows machine installed in C:\
Kibana is running on localhost:5601.
I installed NGinx and configured it to run on port 80. My config file of Nginx looks like this.
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
server {
listen 80;
server_name 127.0.0.1:5601;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ {
proxy_pass http://127.0.0.1:5601;
#proxy_redirect https://kibana/;
}
}
But when i enter localhost in my browser i see,
"Welcome to nginx!
If you see this page, the nginx web server is successfully installed and working. Further configuration is required.
For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.
Thank you for using nginx."
Kibana is working fine with : localhost:5601.
Do i need to make any changes to the Kibana config file also? I want to access the kibana dashboard by localhost:80 through NGinx.
Thanks

Change "server_name 127.0.0.1:5601;" to "server_name localhost:80;"
Add this upstream above "server {" :
upstream kibana {
server localhost:5601;
}
and then replace "location ~" with :
location /kibana/ {
proxy_pass http://kibana/;
}
Use http://localhost/kibana to access Kibana

I have configured my nginx to reverse proxy the kibana-4 dashboard. The following nginx config does the job for me:
server {
listen 80;
#You can add your fqdn, say example.com, if you want to in the next parameter
server_name localhost;
auth_basic off;
location / {
proxy_pass http://localhost:5601;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}

here is how you can proxy to kibana through nginx kibana and ES on a remote server with https using letencrypt
server {
listen [some_port] ssl http2;
server_name [server_name];
root /your/root/directoty;
location /app {
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/conf.d/yyyyyyyyy.passwd;
proxy_pass http://example.com:5601;
}
location /bundles {
proxy_pass http://example.com:5601/bundles;
}
location /elasticsearch {
proxy_pass [http://elasticsearch_server:9200;]
}
location /status {
proxy_pass http://example.com:5601/status;
}
location /api {
proxy_pass http://example.com:5601/api;
}
location /plugins {
proxy_pass http://example.com:5601/plugins;
}
location /ui {
proxy_pass http://example.com:5601/ui;
}
location /es_admin {
proxy_pass http://example.com:5601/es_admin;
}
location /built_assets {
proxy_pass http://example.com:5601/built_assets;
}
location /node_modules {
proxy_pass http://example.com:5601/node_modules;
}
location /translations {
proxy_pass http://example.com:5601/translations;
}
location /internal {
proxy_pass http://example.com:5601/internal;
}
ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/yourdomain.com/chain.pem;
include snippets/ssl.conf;
include snippets/letsencrypt.conf;
access_log /var/log/nginx/xxxx.access.log;
error_log /var/log/nginx/xxxxx.error.log;
passenger_enabled on;
passenger_min_instances 1;
client_max_body_size 10m;
}

Related

nginx domain with and without wildcard

I have nginx configuration file which has to server example.com and www.example.com.
server {
listen 80;
server_name example.com;
return 301 http://www.example.com$request_uri;
}
server {
listen 80;
server_name www.example.com;
auth_basic "example Login";
auth_basic_user_file /etc/nginx/.htpasswd;
root /projects/www/example;
index index.html;
location ~* \.(html|js|jpg|png|gif|css|perfumes|imgs|map|fonts|otf)$ {
index index.do index.html index.htm;
access_log off;
}
location /.protected {
access_log off;
auth_basic off;
}
location /health {
access_log off;
auth_basic off;
}
location / {
try_files $uri $uri/index.html;
}
location /hello {
proxy_pass http://localhost:8282;
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;
}
}
I am trying to protect this domain for now, cuz we are preparing the launch. But there is only link which should let the requests pass through without password, if a link has '.protected' in it.
For example,
www.example.com/.protected/file1.txt should be allowed without entering a password.
It is working ok, but the issue is example.com/.protected/file1.txt (without 'www').
If I type only domain name 'example.com' (without 'www'), it automatically redirects to www.example.com as configured, but 'example.com/.protected/file1.txt' doesn't redirect to 'www.example.com/.protected/file1.txt'. It seems if the domain name has some paths, the domain name (without 'www') doesn't redirect to 'www.example.com'
I am getting 'curl: (6) Could not resolve host:'
Is there anything wrong with my configuration file?

Nginx adding domain

Setting up a site on digitalocean it's working on a default ip that comes with the setup. I've added a domain to the instance and edited the nginx conf file to add a subdomain for testing purposes. I've restarted nginx but the changes aren't taking effect. Here's the conf settings.
upstream app_server {
server unix:/home/django/gunicorn.socket fail_timeout=0;
}
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
index index.html index.htm;
client_max_body_size 4G;
server_name _ beta.kazi-connect.com;
keepalive_timeout 5;
# Your Django project's media files - amend as required
location /media {
alias /home/django/django_project/django_project/media;
}
# your Django project's static files - amend as required
location /static {
alias /home/django/django_project/django_project/static;
}
# Proxy the static assests for the Django Admin panel
location /static/admin {
alias /usr/lib/python2.7/dist-packages/django/contrib/admin/static/admin/;
}
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
proxy_buffering off;
proxy_pass http://app_server;
}
}

Two Play deployments servers on the one physical server

I want to have two Play Framework deployments on the same server and configure nginx to redirect the locations accordingly.
I have this configuration:
server {
listen 80;
server_name localhost;
client_max_body_size 20M;
location /site2 {
proxy_pass http://localhost:8000/;
}
location / {
proxy_pass http://localhost:9000/;
}
}
But it does not work.
What I want is:
When I use: http://ip/ or http://ip/something the Play deployment at port 9000 should respond.
When I use: http://ip/site2/ or http://ip/site2/something the Play deployment at port 8000 should respond.
First, please check that you have access to each app directly:
ip:8000
ip:9000
Next please add proxy_redirect directive:
server {
listen 80;
server_name localhost;
location /site2 {
proxy_pass http://localhost:8000/;
proxy_redirect http://localhost/site2/ http://localhost:8000/;
}
location / {
proxy_pass http://localhost:9000/;
proxy_redirect http://localhost/ http://localhost:9000/;
}
}

Nginx: setting the error page to a static file

I have the following nginx configuration:
server {
listen 80;
server_name default;
location / {
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:8080/;
}
}
When the internal service at http://127.0.0.1:8080/ is not responding nginx return a 502 Bad Gatway error.
My question: how can I configure nginx to returning a static html file, e.g. /var/www/error.html, when such error occurs?
What I tried
Taking a cue from here I tried this:
server {
listen 80;
server_name default;
location / {
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:8080/;
}
error_page 404 502 /error.html;
location = /error.html {
internal;
root /var/www;
}
}
It's working fine if the service (on the port 8080) is down, but when the service is up and I try to access the url /error.html nginx match the last location (returning me the static file) and I would like to avoid it.
Well, if you really don't want to expose error page, you could use named location.
server {
listen 80;
server_name default;
location / {
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:8080/;
# probably you also need this
# proxy_intercept_errors on;
}
error_page 404 502 #error;
location #error {
root /var/www;
try_files /error.html /error.html;
}
}

nginx and monit web interface - how to have monit on domain.com/monit versus domain.com

I am using monit on my ec2 instance and I am new to nginx. Below is my nginx config file:
server {
listen 80;
server_name 127.0.0.1;
location / {
proxy_pass 127.0.0.1:2812;
proxy_set_header Host $host;
}
}
So..if I go to domain.com I see monit. How do I modify above code where I can see monit on domain.com/monit?
Thanks
Please, try this:
server {
listen 80;
server_name 127.0.0.1;
location /monit/ {
proxy_pass http://127.0.0.1:2812;
proxy_set_header Host $host;
}
}
Please, read more here about how directive location works in nginx
There's an article in Monit's wiki how to configure it with Nginx.
Here's my /etc/nginx/conf.d/monit.conf:
server {
listen 80;
server_name my.server.name;
location /monit/ {
allow 127.0.0.1;
allow 192.0.0.0/8;
deny all;
proxy_pass http://127.0.0.1:2812;
proxy_set_header Host $host;
rewrite ^/monit/(.*) /$1 break;
proxy_ignore_client_abort on;
}
}
Sergei already correctly answered your direct question. I think it's also worth noting that this may be cleaner to just use a subdomain:
server {
listen 80;
server_name monit.domain.com;
location / {
proxy_pass 127.0.0.1:2812;
proxy_set_header Host $host;
}
}

Resources