All Products
Search
Document Center

Function Compute:Configure Basic authentication for a custom domain name

Last Updated:Apr 01, 2026

Basic authentication lets you restrict access to a Function Compute custom domain name using a username and password. Requests without valid credentials are rejected before reaching your function.

Prerequisites

Before you begin, ensure that you have:

Before you enable

ConsiderationDetails
User limitUp to 20 users per custom domain name
Username format12–128 characters; must start with a letter; hyphens (-), underscores (_), and periods (.) allowed
Password requirements12–128 characters; must include uppercase letters, lowercase letters, digits, and at least one of: ! @ # $ % ^ & * ( )
Password hygieneDon't reuse passwords or use simple combinations; rotate passwords regularly
ProtocolUse HTTPS in production. HTTP is for testing only — you are responsible for any credential leaks over HTTP
Configuration delayAllow 1 minute for changes to take effect

Configure Basic authentication

  1. Log in to the Function Compute console. In the left-side navigation pane, choose Advanced Features > Custom Domains.

  2. In the top menu bar, select a region. On the Domain Names page, find your custom domain name and click Edit in the Actions column.

  3. On the settings page, expand Authentication Settings and set Authentication Method to Basic Authentication.

  4. Under User List, click Add User and enter a Username and Password.

    For format requirements, see Before you enable.

  5. Click Save.

    image

    Wait 1 minute for the configuration to take effect.

Verify Basic authentication

After configuration takes effect, test that authentication is working correctly.

  1. Generate a Base64-encoded credential. Run the following command — use the -n flag to prevent a trailing newline from being included in the encoding:

    # Linux/macOS
    echo -n "username:password" | base64

    Example output:

    dXNlcm5hbWU6cGFzc3dvcmQ=
  2. Send a test request using the encoded credential:

    curl -X GET "yourCustomdomain" -H "Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ="

    Replace yourCustomdomain with your actual custom domain name.

Troubleshooting

`authorization required`

The request reached the domain but the Authorization header is missing or its value is incorrect. Check that the header is present and that the encoded credentials match a configured user.

`basic authorization xxx is not a Base64-encoded string`

The value in the Authorization header is not valid Base64. Re-run the encoding command and copy the output exactly.

`Authorization header must start with Basic`

Per RFC 7617, the Authorization header value must start with Basic followed by a space — for example, Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=. Check for missing spaces or extra characters.

FAQ

Does enabling Basic authentication incur extra charges?

No. Function Compute bills based on the number of function invocations, so enabling Basic authentication has no effect on your bill.