How to Enable Authentication for the Kibana Dashboard Using Apache Web Server on CentOS 7

Post Date: November 7, 2020
Last Updated: November 17, 2026

Introduction

Kibana is an open-source data visualization and exploration platform used with Elasticsearch. It provides a web-based interface for monitoring, managing, searching, and visualizing data collected in the Elastic Stack.

The Kibana dashboard displays information through charts, graphs, metrics, searches, and maps, allowing administrators to analyze data from a centralized interface.

Kibana provides built-in authentication through Elasticsearch security in modern Elastic Stack versions. However, you may also want to add an additional authentication layer using the Apache web server to restrict access to the dashboard.

In this article, we will explain how to configure Apache Basic Authentication as an additional security layer for a Kibana dashboard using a reverse proxy.

Note: CentOS 7 reached end of life on June 30, 2024. It no longer receives regular security updates. The following instructions are intended for maintaining or understanding legacy CentOS 7 environments. For new deployments, use a supported operating system.

Prerequisites

Before configuring Apache authentication for Kibana, ensure that you have:

  • A CentOS 7 server with administrative or root access.
  • Kibana installed and running.
  • Elasticsearch configured and accessible.
  • Apache HTTP Server installed or permission to install it.
  • A domain name pointing to the server, such as monitor.example.com.
  • A valid SSL/TLS certificate for secure HTTPS access.

In this example, we use the following configuration:

ComponentConfiguration
Operating systemCentOS 7
Web serverApache HTTP Server
Kibana port5601
Kibana address127.0.0.1
Domainmonitor.example.com
AuthenticationApache Basic Authentication

Steps to Enable Authentication for the Kibana Dashboard Using Apache

Step 1: Install the Apache Web Server

First, install the Apache HTTP Server and the tools required to create password-protected users.

Run the following command:

yum install httpd httpd-tools mod_ssl -y

Enable and start the Apache service:

systemctl enable httpd
systemctl start httpd

Check the Apache service status:

systemctl status httpd

Step 2: Create a Username and Password for Kibana

After installing Apache, create a username and password using the htpasswd utility.

Run the following command:

htpasswd -cB /etc/httpd/conf/.htpasswd kibanaadmin

You will be prompted to enter and confirm a password:

New password:
Re-type new password:
Adding password for user kibanaadmin

Here:

  • -c creates a new password file.
  • -B uses bcrypt password hashing.
  • /etc/httpd/conf/.htpasswd is the password file location.
  • kibanaadmin is the username created for dashboard access.

Set appropriate permissions on the password file:

chown root:apache /etc/httpd/conf/.htpasswd
chmod 640 /etc/httpd/conf/.htpasswd

Note: Use the -c option only when creating the password file for the first time. If you want to add another user to the existing file, run:

htpasswd -B /etc/httpd/conf/.htpasswd anotheruser

Using -c again will overwrite the existing password file and remove its previous users.

Step 3: Configure Kibana to Listen on Localhost

By default, Kibana commonly uses port 5601. To ensure that users access the dashboard through Apache rather than connecting directly to Kibana, configure Kibana to listen only on the local interface.

Open the Kibana configuration file:

vi /etc/kibana/kibana.yml

Set the following configuration:

server.port: 5601
server.host: "127.0.0.1"

Save the file and restart Kibana:

systemctl restart kibana

Verify that Kibana is listening on the local address:

ss -lntp | grep 5601

The expected listening address should be 127.0.0.1:5601.

This prevents external users from bypassing Apache’s authentication by accessing port 5601 directly.

Step 4: Configure Apache as a Reverse Proxy with Basic Authentication

Now configure Apache to forward requests to Kibana and require a username and password before allowing access.

Create a new Apache configuration file:

vi /etc/httpd/conf.d/kibana.conf

Add the following configuration:

<VirtualHost *:80>
    ServerName monitor.example.com

    ProxyPreserveHost On
    ProxyRequests Off

    ProxyPass / http://127.0.0.1:5601/
    ProxyPassReverse / http://127.0.0.1:5601/

    # Protect the Kibana dashboard with Basic Authentication
    <Location />
        AuthType Basic
        AuthName "Restricted Content"
        AuthUserFile /etc/httpd/conf/.htpasswd
        Require valid-user
    </Location>

</VirtualHost>

Replace monitor.example.com with your actual domain name.

Explanation of the configuration:

  • ProxyPreserveHost On: Preserves the original Host header when forwarding requests to Kibana.
  • ProxyRequests Off: Disables forward proxy functionality. This is the recommended setting for a reverse proxy.
  • ProxyPass: Forwards incoming requests to the Kibana service running on port 5601.
  • ProxyPassReverse: Adjusts response headers when required for reverse proxy operation.
  • AuthType Basic: Enables HTTP Basic Authentication.
  • AuthName: Defines the authentication prompt displayed by the browser.
  • AuthUserFile: Specifies the file containing the authentication usernames and password hashes.
  • Require valid-user: Allows access only to users listed in the password file.

Apache requires the appropriate proxy modules, including mod_proxy and mod_proxy_http, to be available and loaded.

Step 5: Configure HTTPS for Secure Authentication

Basic Authentication sends credentials using an HTTP authentication header. Without HTTPS, these credentials are not encrypted during transmission.

Therefore, configure an SSL/TLS certificate for your domain before exposing the dashboard publicly.

For example, if you use a Let’s Encrypt certificate, configure an HTTPS virtual host in your Apache configuration:

<VirtualHost *:443>
    ServerName monitor.example.com

    SSLEngine on
    SSLCertificateFile /etc/letsencrypt/live/monitor.example.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/monitor.example.com/privkey.pem

    ProxyPreserveHost On
    ProxyRequests Off

    ProxyPass / http://127.0.0.1:5601/
    ProxyPassReverse / http://127.0.0.1:5601/

    <Location />
        AuthType Basic
        AuthName "Restricted Content"
        AuthUserFile /etc/httpd/conf/.htpasswd
        Require valid-user
    </Location>

</VirtualHost>

You should also redirect HTTP requests to HTTPS. Add the following virtual host:

<VirtualHost *:80>
    ServerName monitor.example.com
    Redirect permanent / https://monitor.example.com/
</VirtualHost>

Make sure the certificate paths match the actual certificate installation on your server.

Step 6: Check and Restart the Apache Service

Before restarting Apache, validate the configuration:

httpd -t

If the configuration is valid, you should see:

Syntax OK

Restart Apache to apply the changes:

systemctl restart httpd

Check the service status:

systemctl status httpd

If Apache fails to start, review the error logs:

tail -50 /var/log/httpd/error_log

Step 7: Configure Firewall and SELinux (If Required)

If firewalld is enabled, allow HTTP and HTTPS traffic:

firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
firewall-cmd --reload

If SELinux is enforcing, Apache may be prevented from connecting to Kibana on port 5601.

Allow Apache to establish network connections:

setsebool -P httpd_can_network_connect 1

Do not expose port 5601 publicly. External dashboard access should go through Apache.

Step 8: Access the Kibana Dashboard

Once the configuration is complete, open a web browser and access your domain:

https://monitor.example.com

The browser should display an authentication prompt requesting a username and password.

Enter the credentials created in Step 2:

  • Username: kibanaadmin
  • Password: The password configured using htpasswd

After successful authentication, Apache forwards the request to Kibana, and the dashboard should load.

How to Verify Apache Authentication

You can also verify the authentication configuration using the curl command.

First, test without providing credentials:

curl -I https://monitor.example.com

A successful authentication challenge should return:

HTTP/1.1 401 Unauthorized
WWW-Authenticate: Basic realm="Restricted Content"

Next, test with the configured username and password:

curl -I -u kibanaadmin https://monitor.example.com

The command prompts you for the password. After successful authentication, you should receive a response from the proxied Kibana service.

Common Issues and Troubleshooting

1. Apache Returns a 502 Bad Gateway Error

Possible cause: Apache cannot connect to Kibana on port 5601.

Solution: Check whether Kibana is running:

systemctl status kibana

Verify that Kibana is listening on the expected address:

ss -lntp | grep 5601

Also check Apache’s error log and SELinux settings.

2. Apache Returns a 403 Forbidden Error

Possible cause: Apache cannot access the password file, or the authentication configuration is incorrect.

Solution: Verify the password file permissions:

ls -l /etc/httpd/conf/.htpasswd

Ensure the Apache service account can read the file and that the AuthUserFile path is correct.

3. Browser Does Not Display the Authentication Prompt

Possible cause: The authentication directives are missing, incorrectly configured, or applied to a different URL location.

Solution: Verify the <Location /> configuration and ensure Apache has loaded the required authentication modules. Validate and restart Apache after making changes.

4. Kibana Is Accessible Directly Through Port 5601

Possible cause: Kibana is listening on an externally accessible interface.

Solution: Set server.host: "127.0.0.1" in kibana.yml, restart Kibana, and ensure firewall rules prevent external access to port 5601.

5. Apache Cannot Connect to Kibana Because of SELinux

Possible cause: SELinux is preventing Apache from making network connections to the Kibana backend.

Solution: Check the SELinux status and allow the required connection:

getenforce
setsebool -P httpd_can_network_connect 1

Apache Basic Authentication vs. Kibana Built-in Authentication

Apache Basic Authentication and Kibana’s built-in authentication serve different purposes.

FeatureApache Basic AuthenticationKibana Built-in Authentication
Authentication layerApache web serverElasticsearch security
User managementApache password fileElasticsearch users and realms
Role-based accessNot provided by Apache Basic Authentication aloneSupported through Elasticsearch roles
Authentication promptBrowser-level HTTP promptKibana login page
Main purposeAdd an access restriction in front of KibanaAuthenticate users and control application access

For modern Elastic Stack deployments, Kibana’s built-in authentication is generally the recommended approach. Apache Basic Authentication can be used as an additional access-control layer when required.

Conclusion

Securing the Kibana dashboard is important because it may contain sensitive monitoring information, application metrics, and operational data.

Apache Basic Authentication provides an additional layer of protection by requiring users to enter valid credentials before accessing the Kibana dashboard. By configuring Apache as a reverse proxy, creating an htpasswd file, and enabling HTTPS, you can restrict external access to the dashboard.

Frequently Asked Questions (FAQs)

1. Does Kibana support authentication by default?

Modern Kibana versions support built-in authentication through Elasticsearch security. Authentication can be configured using supported security realms and authentication providers.

2. Why use Apache Basic Authentication for Kibana?

Apache Basic Authentication adds an additional access restriction in front of the Kibana dashboard. It can prevent unauthorized visitors from reaching the Kibana interface before they authenticate.

3. Which port does Kibana use by default?

Kibana uses port 5601 by default. Apache can act as a reverse proxy so users can access Kibana through a domain name without specifying the backend port.

4. Is HTTPS required when using Apache Basic Authentication?

HTTPS is strongly recommended. Basic Authentication does not encrypt credentials by itself, so using it over plain HTTP can expose credentials during transmission.

5. Can I use Apache authentication and Kibana authentication together?

Yes. Apache can require an additional username and password before forwarding requests to Kibana. Kibana can then perform its own authentication and authorization through Elasticsearch security.

References

Need Assistance?

Need help securing your Kibana dashboard, configuring Apache reverse proxies, or implementing authentication for your Elastic Stack environment?

The Pheonix Solutions technical team can assist you with Linux server administration, Apache configuration, Elasticsearch, Kibana, and infrastructure security.

For assistance, contact us.

admin

Our team has expertise across software and web development, WordPress, e-commerce, mobile applications, UI/UX, cloud and infrastructure, DevOps, CI/CD, API integration, security, testing, automation, and technical support. The team also works with AI-based software solutions, LLMs, AI workflows, AI agents, and intelligent application development to help businesses automate processes and build smarter digital solutions. We focus on developing, deploying, maintaining, and optimising secure, scalable, and reliable technology solutions while helping businesses adopt modern technologies and drive digital transformation.

Leave a Comment

Scroll to Top