1. Vấn đề cần giải quyết

2. Giới thiệu Nginx và vận hành Nginx Reverse Proxy for Kibana

2.1 Giới thiệu Nginx

Nginx là một máy chủ Web Server mã nguồn mở. Dự án Nginx được phát hành và sử dụng như một web server được thiết kế hướng đến mục đích cải thiện tối đa hiệu năng và sự ổn định.

Dùng Nginx làm Reverse Proxy cho Kibana giúp tăng cường bảo mật bằng cách thêm xác thực và mã hóa SSL/TLS, và nhiều lợi ích khác mà một webserver có thể mạng lại.

2.2 Sử dụng Nginx làm Reverse proxy

# cài đặt nginx
$ sudo apt update
$ sudo apt install nginx apache2-utils -y
$ systemctl start nginx
$ systemctl enable nginx
# cấu hình nginx
$ vi /etc/nginx/conf.d/kibana.conf
server {
    set $forward_scheme http;
    set $server         "<YOUR-KIBANA-IP>";
    set $port           5601;

    listen 80;
    listen [::]:80;

    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    server_name <YOUR-DOMAIN>;

    if ($scheme = "http") {
        return 301 https://$host$request_uri;
}

    # Custom SSL examble
    # ssl_certificate /data/custom_ssl/npm-12/STAR_bhbl_vn/bhbl.crt;
    # ssl_certificate_key /data/custom_ssl/npm-12/STAR_bhbl_vn/bhbl.key;
    ssl_certificate <YOUR-PATH>
    ssl_certificate_key <YOUR-PATH>

    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $http_connection;
    proxy_http_version 1.1;

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    location / {
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-Scheme $scheme;
        proxy_set_header X-Forwarded-Proto  $scheme;
        proxy_set_header X-Forwarded-For    $remote_addr;
        proxy_set_header X-Real-IP          $remote_addr;
        proxy_pass       http://<YOUR-KIBANA-IP>:5601;

        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $http_connection;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'update';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_update;
    }

    # Custom
}
# khởi động lại Nginx
$ systemctl restart nginx
$ systemctl status nginx

Untitled