The .well-known folder: a practical guide to its purpose, setup and security in modern websites

In the modern web, certain directories are standardised to support automated processes, security validations, and cross‑service communications. The .well-known folder is one such directory. Positioned at the root of your website, this small, well-defined location hosts a range of resources that services and tooling expect to find in predictable places. When used correctly, the .well-known folder simplifies domain validation, policy provisioning, and metadata discovery, helping maintain interoperability across platforms while keeping your site’s configuration clean and organised.
What is the .well-known folder?
The .well-known folder is a publicly accessible, conventional directory that hosts files and subpaths used by automated systems. Its purpose is collaboration—by providing standard URLs for specific metadata, certificates, and policies, it reduces the friction involved in setting up services that need to verify domain ownership or obtain configuration data. The name itself—well-known with the leading dot—signals to servers and tooling that these are machine-readable resources rather than human‑facing content. The typical URL structure looks like https://yourdomain.example/.well-known/…
Crucially, the contents of the .well-known folder are not arbitrary. Each resource has a defined role in standards and best practices. For example, a validator or certificate authority might request a token from the path .well-known/acme-challenge or expect discovery information from .well-known/openid-configuration. Understanding this framework helps administrators plan how to expose or protect these resources without exposing sensitive data.
Why the .well-known folder matters
There are several reasons why the .well-known folder is important for both site owners and external services. First, it provides a predictable, standards-based location for automated checks and configurations. This predictability is essential for domain validation during SSL certificate issuance, for implementing security policies, and for enabling features like open standards-based authentication or app association on mobile devices. Second, it centralises important metadata in a single, auditable place. When the .well-known folder is properly maintained, administrators can audit, update, and rotate resources with confidence. Finally, using the .well-known folder correctly reduces the risk of misconfigurations and security gaps that can occur when files are stored in ad hoc locations scattered across a site.
Common uses of the .well-known folder
Across the web, the .well-known folder hosts a variety of standard resources. Here are some of the most common and what they do:
ACME challenges: the .well-known/acme-challenge path
When obtaining or renewing certificates from a certificate authority that supports the Automated Certificate Management Environment (ACME), Let’s Encrypt and similar services use the ACME challenge mechanism. The authentication token is placed in the ACME subpath under the .well-known folder, for example, / .well-known/acme-challenge/your-token. The CA will then verify this token by issuing an HTTP(S) request to that URL. It is essential that this path remains publicly accessible while the verification is in progress, and that the content is exactly the token provided by the ACME client. Misconfigurations here commonly lead to failed certificate issuance, even though your site is otherwise healthy.
security.txt: declaring security policies through the .well-known folder
The security.txt standard aims to provide a simple, machine-readable way for security researchers to contact a website’s security team. Placing a file at /.well-known/security.txt enables automated scanners to discover responsible disclosure information quickly. This small file typically includes contact details, policy statements, and disclosure guidelines. Implementing security.txt in the .well-known folder demonstrates a proactive security posture and can reduce friction in reporting potential issues.
OpenID Connect discovery: the .well-known/openid-configuration endpoint
OpenID Connect is a widely adopted standard for federated authentication. The .well-known/openid-configuration resource provides a JSON document that describes the provider’s endpoints, supported features, and other metadata. Clients rely on this configuration to initiate authentication flows without manual configuration per provider. Hosting the openid-configuration in the .well-known folder aligns with established discovery practices and simplifies integration with multiple identity providers.
Other metadata and services: .well-known paths
Beyond ACME and OpenID, several other protocols and platforms use the .well-known folder. Examples include /.well-known/apple-app-site-association for iOS universal links, /.well-known/webfinger for resource discovery, and various platform-specific configurations. While not every site will utilise all of these endpoints, awareness of them helps administrators plan for potential integrations without introducing unexpected exposure.
Access paths and URL structure of the .well-known folder
The URL structure of the .well-known folder follows a predictable pattern that makes automation reliable. Each resource under the .well-known directory is accessed by a path that starts with a leading slash, then the domain, followed by / .well-known / and the specific resource name. For example:
- https://yourdomain.example/.well-known/acme-challenge/abcdef123456
- https://yourdomain.example/.well-known/openid-configuration
- https://yourdomain.example/.well-known/security.txt
- https://yourdomain.example/.well-known/apple-app-site-association
When planning to implement the .well-known folder, remember to consider how it interacts with your web server’s routing, redirects, and caching policies. If a proxy or CDN sits in front of your origin, ensure it forwards requests to the origin for these resources or caches them appropriately, depending on how dynamic or sensitive the data is. In many setups, ACME challenges are transient and must not be cached aggressively, whereas static provider discovery documents may be cached with longer TTLs if they are unlikely to change frequently.
Configuring the .well-known folder on Apache
Apache users can implement and protect the .well-known folder using a few straightforward steps. The key is to ensure the directory exists within the document root, is readable by the web server, and is not exposed to directory listing.
Step 1: Create and locate the directory
Within your site’s document root, create the .well-known directory if it does not already exist. For many installations, this will be something like /var/www/html/.well-known. Use the correct permissions so that the web server can read files placed there.
Step 2: Set permissions and ownership
Assign an appropriate user and group to the directory and its contents. A common approach is to set the web server user (often www-data on Debian-based systems or apache on Red Hat-based systems) as the owner, with permissions that allow reading by the server but not writing by the public. For example, a typical setup might be chown -R www-data:www-data /var/www/html/.well-known and chmod -R 755 /var/www/html/.well-known, with more restrictive permissions for sensitive files if required.
Step 3: Disable directory listing
To prevent exposing the contents of the folder to visitors, disable directory listing for the .well-known directory. In Apache, you can add a rule to your site’s Directory block or an .htaccess file:
Options -Indexes
This ensures that only explicitly served files are accessible, reducing the risk of information disclosure.
Step 4: Define explicit content types and access rules
Ensure that files placed in the .well-known folder are served with correct content types. For static resources such as security.txt, acme-challenge tokens, and discovery documents, the default MIME mappings are typically sufficient, but you should verify that the correct Content-Type headers are being delivered. If needed, you can configure MIME types in Apache’s configuration to guarantee consistent delivery.
Step 5: Test coverage and validation
After you’ve placed resources in the .well-known folder, test access with a browser or a command-line tool. For example, curl -I https://yourdomain.example/.well-known/openid-configuration should return a 200 OK status and a valid JSON payload for the OpenID configuration. Regular checks help catch misconfigurations early and minimise downtime during certificate issuance or policy retrieval.
Configuring the .well-known folder on Nginx
Nginx configurations differ from Apache but share the same underlying goals: expose only what is necessary, keep directory listings off, and maintain predictable paths for automated tools.
Step 1: Ensure the directory exists and is readable
Place the .well-known directory within your site’s root, for example /usr/share/nginx/html/.well-known, and ensure it is readable by the Nginx worker processes. Ownership and permissions should mirror best practices for your environment.
Step 2: Disable directory listing and enforce access control
In Nginx, directory listing is controlled by configuration blocks. Add a location block for the .well-known directory to explicitly allow or deny access. A simple, secure approach is to serve only known resources and deny everything else:
server {
listen 443 ssl;
server_name yourdomain.example;
location ^~ /.well-known/ {
allow all;
default_type application/octet-stream;
try_files $uri =404;
}
}
This configuration prevents directory listing while ensuring legitimate resources can be served. If you have security-related files, consider restricting extractable data or limiting access to specific IP ranges where appropriate, particularly during sensitive operations.
Step 3: Maintain performance with appropriate caching
For static resources that do not change frequently, you can apply caching headers to improve performance. For example, you could add:
location ^~ /.well-known/ {
expires 30d;
add_header Cache-Control "public";
}
Be mindful that ACME challenge content is ephemeral and should not be cached for long periods. If you actively use ACME, you may wish to disable long-term caching for the acme-challenge path specifically.
Step 4: Validate and monitor
As with Apache, verify that the endpoints under the .well-known folder respond correctly. Use curl -I to check headers and status codes, and review Nginx logs for any unexpected errors or access attempts that indicate misconfiguration.
Testing and verifying access to the .well-known folder
Regular verification is essential for ensuring that the .well-known folder remains available to automated systems. Here are practical steps you can follow:
- Run a quick HTTP HEAD request for the specific resources, such as /.well-known/openid-configuration and /.well-known/security.txt, to confirm they return 200 or 301 statuses as expected.
- Validate the content of dynamic resources, for example, ensure that the ACME challenge token returned at /.well-known/acme-challenge/ matches what your ACME client provided.
- Test from different geographic locations if possible, to ensure there are no regional blocks or CDN misconfigurations affecting access.
In practice, a simple set of curl commands can be invaluable. For instance:
curl -I https://yourdomain.example/.well-known/openid-configuration curl -I https://yourdomain.example/.well-known/security.txt curl -I https://yourdomain.example/.well-known/apple-app-site-association
These checks help catch issues early, particularly during certificate renewals or provider metadata updates.
Security considerations for the .well-known folder
Exposing resources through the .well-known folder should not create security vulnerabilities. Here are key considerations to keep things safe and resilient.
- Only store non‑sensitive, machine-readable resources in the .well-known folder. Do not place private tokens, passwords, or secrets in this directory.
- Serve all resources over HTTPS to prevent interception or tampering during transit. This is especially important for security-related files such as security.txt and OpenID configuration.
- Disable directory listing and enforce strict access controls. The goal is to expose only the intended files, not the entire directory structure.
- Regularly review the contents of the .well-known folder to remove deprecated or outdated files. Consider versioning approaches for long‑lived configurations so updates are controlled.
- Be mindful of caching policies. While static discovery documents can benefit from caching, ephemeral ACME challenges must always be served fresh and not cached beyond the necessary verification window.
Common pitfalls and best practices
Even with a clear standard, mistakes can creep in. Here are common pitfalls related to the .well-known folder and practical best practices to avoid them.
- Forgetting to create the directory in the correct document root. Always double-check the web server’s root path, especially when multiple sites share a server.
- Allowing directory listing or broad access. Ensure that .well-known is protected and that only intended resources are served publicly.
- Incorrect content types or encoding. Validate that the MIME type for discovery documents is appropriate to their format (JSON for openid-configuration, plain text for security.txt, etc.).
- Misplacing resources during migrations or hosting changes. When moving to a new host or container, verify that the .well-known folder is migrated intact and accessible.
- Neglecting to update the resources after major platform changes. If a provider changes its discovery document or new ACME challenges are introduced, update promptly to avoid failed validations.
Automation, tooling and the .well-known folder
Automated tools and CI/CD pipelines frequently interact with the .well-known folder. For instance, the ACME client automates the placement of challenge tokens, and the identity provider may pull configuration from /.well-known/openid-configuration during client integration. When designing deployment workflows, consider including steps to:
- Validate presence and correctness of required resources after deployments or restarts.
- Share a small, version-controlled template or script for creating the .well-known resources so teams can reproduce configurations across environments.
- In containerised environments, ensure the volume mounted for the site includes the .well-known folder and survives restarts or container replacements.
- In fronted by a CDN, configure edge rules so that ACME challenges are forwarded to origin and not cached, while static, non-sensitive discovery data can be cached at the edge if appropriate.
Maintaining the .well-known folder in dynamic hosting environments
Cloud platforms, container orchestration, and serverless hosting all introduce dynamics that can affect the .well-known folder. Consider these strategies to keep this folder reliable under changing conditions:
- Include the .well-known folder in all deployment artefacts and ensure it is present in every environment (dev, staging, production).
- Use explicit paths and avoid rewriting rules that unintentionally redirect or mask /.well-known resources.
- Implement health checks that specifically verify the availability of at least the essential endpoints under the .well-known folder, such as acme-challenge and security.txt, to detect outages quickly.
- Document the intended contents and purpose of the .well-known folder in runbooks or internal wikis so future operators understand why certain files exist there and how to update them safely.
Case studies: practical scenarios involving the .well-known folder
To illustrate how the .well-known folder functions in real-world settings, consider a few typical scenarios:
Scenario 1: A small business obtaining an SSL certificate
A small business hosting its site behind a modest LAMP stack uses Let’s Encrypt for SSL. The administrator places the token for ACME validation in /.well-known/acme-challenge/ and ensures the directory is publicly readable for the duration of the validation window. Once the certificate is issued, the file is removed or replaced with a standard placeholder. This straightforward workflow highlights the importance of a stable, accessible .well-known folder without exposing sensitive information.
Scenario 2: An enterprise deploying OpenID Connect
In a federated authentication environment, the identity provider publishes an OpenID Connect configuration at /.well-known/openid-configuration. Applications discover endpoints programmatically, enabling seamless sign-on experiences across multiple services. The enterprise maintains a consistent mechanism for updating these configurations and validates changes through automated tests to ensure compatibility with diverse client libraries.
Scenario 3: Mobile apps and Apple universal links
Mobile applications relying on universal links require the Apple app site association file located at /.well-known/apple-app-site-association. The deployment process accounts for this file so that iOS devices can establish secure app linkages to the corresponding website. Regular audits confirm that the file remains intact and aligned with the app’s entitlements.
Conclusion
The .well-known folder is a small but powerful component of modern web architecture. By providing standard, machine-readable resources at predictable paths, it enables automated validation, secure policy distribution, and smooth metadata discovery. Properly configuring and maintaining the .well-known folder reduces the risk of certificate issues, misconfigurations, and interoperability problems, while keeping your site’s layout clean and straightforward. Whether you operate a single-domain site or an extensive, multi-service environment, thoughtful management of the .well-known folder will pay dividends in stability, security, and ease of integration for years to come.
In short, the .well-known folder is not just a directory; it is a deliberate design choice that supports automation, security, and best practices across the web. By understanding its purposes, implementing it carefully on Apache or Nginx, and regularly testing its resources, you can leverage the full benefits of this standard area of your site and ensure reliable interactions with external services and clients.