All Products
Search
Document Center

Managed Service for Grafana:Customize a private domain name

Last Updated:May 13, 2025

The custom private domain name feature of Managed Service for Grafana allows you to resolve your Grafana workspace to a specified domain name, meeting individual or enterprise requirements for unified domain names.

Preparations

  • Go to the Workspace Information page of the Grafana workspace, and enable the private domain name in the Basic Information section.100

  • Obtain the private domain name of the workspace.99

Method 1: Customize an HTTP private domain name

Note

This example demonstrates how to customize a private domain name using Private DNS.

  1. Activate Private DNS.

  2. Log on to the Alibaba Cloud DNS console.

  3. On the Private DNS (PrivateZone) page, click Add New Zone. In the panel that appears, set Built-in Authoritative Zone, and then click OK.

    97

  4. On the User Defined Zones tab of the Private DNS (PrivateZone) page, click the new zone. On the Resource Records Settings tab of the page that appears, click Add Record, and then set the parameters in the Add Record panel, as shown in the following figure.87

    Parameter

    Description

    Example

    Record Type

    Select CNAME, indicating that the domain name points to another domain name.

    CNAME

    Hostname

    Fill in the domain name prefix.

    @

    Request Line

    Select Default.

    Default

    Record Value and Load Balancing Policy

    Record Value: Enter the private domain name of the Grafana workspace.

    Weight: 1

    Record Value: grafana-cn-kjp**-vpc.grafana.aliyuncs.com

    Weight: 1

    TTL

    Select 1 Minute.

    1 Minute

  5. In the Change Resource Record Confirmation message, click OK.85

  6. Set the effective scope of the domain name and select the VPC where the domain name needs to take effect.

    1. Return to the Private DNS (PrivateZone) page, find the zone and click Effective Scope Settings in the Actions column.84

    2. On the Zone Settings tab, select the VPC where the domain name needs to take effect, and click OK.83

  7. Verify whether the domain name is effective on the Elastic Compute Service (ECS) instance in the corresponding VPC.

    Ping grafana.mydomain.com or access http://grafana.mydomain.com directly.image

Method 2: Configure a custom HTTPS private domain name through ECS and NGINX

  1. Install NGINX on an ECS instance.

    Choose an ECS instance to deploy NGINX.

    1. Download and decompress the installation package of NGINX.

      # You can manually download the installation package from the link and then upload it to the server, or you can use the wget command to fetch the installation package directly.
      wget https://nginx.org/download/nginx-1.24.0.tar.gz
      
      # Choose the directory for installing NGINX.
      cp nginx-1.24.0.tar.gz /usr/local/nginx/
      cd /usr/local/nginx/
      tar -zxvf nginx-1.24.0.tar.gz
      cd nginx-1.24.0/
    2. Install SSL dependencies.

      yum -y install make zlib-devel gcc-c++ libtool openssl openssl-devel
    3. Check and set installation parameters.

      ./configure --user=nobody --group=nobody --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_gzip_static_module --with-http_realip_module --with-http_sub_module --with-http_ssl_module
    4. Compile and install NGINX.

      make
      make install
  2. Prepare the SSL certificate.

    Copy the certificate and paste it in the /usr/local/nginx/ssl directory of the ECS instance. Name the certificate files as:

    /usr/local/nginx/ssl/cert.pem
    /usr/local/nginx/ssl/cert.key
  3. Configure NGINX.

    Modify the /usr/local/nginx/conf/nginx.conf file and add the following configuration.

     # HTTPS server
        #
        server {
            listen       443 ssl;
            server_name  grafana.mydomain.com;
    
            ssl_certificate      /usr/local/nginx/ssl/cert.pem;
            ssl_certificate_key  /usr/local/nginx/ssl/cert.key;
    
            ssl_session_cache    shared:SSL:1m;
            ssl_session_timeout  5m;
    
            ssl_ciphers  HIGH:!aNULL:!MD5;
            ssl_prefer_server_ciphers  on;
    
            location / {
                    add_header Access-Control-Allow-Origin *;
                    add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
                    add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
                    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_pass http://grafana-cn-kjp4*******-vpc.grafana.aliyuncs.com:80;  
            }
        }

    Note

    Replace server_name and proxy_pass with actual values:

    • server_name: the custom domain name.

    • proxy_pass: the private domain name of the Grafana workspace.

  4. Check the configuration.

    cd /usr/local/nginx/sbin/
    ./nginx -t

    If the check fails, modify and adjust the configuration file according to the error message. Examples of possible errors include: certificate file not found, incorrect certificate format, configuration format not compliant with NGINX requirements, line break comments not valid, or separators containing Chinese characters.

  5. Start NGINX.

    ./nginx
  6. Configure domain name resolution.

    Refer to Method 1: Customize an HTTP private domain name to set up domain name resolution and configure the effective scope.

    Note

    On the Resource Records Settings tab, add a new record, set the record type to A, and set the record value to the private IP address of the ECS instance.

    88

Method 3: Configure a custom HTTPS private domain name through ALB

  1. Create an Application Load Balancer (ALB) instance.

  2. Add a listener and configure the private IP address.

    1. Confirm the private domain name of the Grafana workspace.

      Ping the private domain name to obtain the IP address.

        ping grafana-cn-kjp4*******-vpc.grafana.aliyuncs.com
      Note

      Generally, the private IP address of a Grafana workspace does not change unless the workspace is stopped or the private domain name is disabled.

    2. Add an HTTPS listener to the ALB instance. Follow these steps to set some important parameters. For more information, see Add an HTTPS listener.

      1. Log on to the SLB console, navigate to ALB > Instances, find the ALB instance and click Create Listener in the Actions column.82

      2. In the Configure Listener step, refer to the following figure to set the parameters.80

      3. In the Configure SSL Certificate step, select an SSL certificate. If you do not have one, click Create SSL Certificate to generate a new SSL certificate.

      4. In the Select Server Group step, set the following parameters.

        Parameter

        Description

        Example

        Server Group Type

        Select IP Type.

        IP Type

        Server Group Name

        Enter a custom server group name.

        Grafana Service

        Note

        Click Add Server to add the private IP address of the Grafana workspace obtained from "Step a", with "Port 80".

      5. Click Submit.

      6. Confirm that the listener status is normal in the listener list.

  3. Configure domain name resolution.

    1. Obtain the VIP (virtual IP address) from the ALB instance details page.image

    2. Configure domain name resolution.

      Refer to Method 1: Customize an HTTP private domain name to set up domain name resolution. Taking Private DNS as an example:

      1. When adding a record, set the record type to A and the host record to @ (adjust according to your specific situation), and then add the ALB instance VIP obtained above as the record value.

      2. Set the effective scope.

    3. Confirm that the domain name is effective.imageimage