Publish: 2022-09-14 | Modify: 2022-09-14
To access your website through Cloudflare, you need to complete a certificate verification process. You are required to place a provided TXT file in a specific directory and ensure it is accessible. If the verification fails, you won't be able to access your website using HTTPS while using Cloudflare. The verification process is shown in the screenshot below:
The usual approach is to create the corresponding directory in your website directory, such as .well-known/pki-validation/
, and then upload the ca3-xxx.txt
file to that directory for verification.
However, if you are using Nginx as your web server, you can simplify the process by using the Nginx location directive to match the verification request.
Add the following content inside the server block of your Nginx site configuration file:
# Cloudflare verification
location ~* /\.well-known.*\.txt {
default_type text/plain;
return 200 'ca3-bb7bcc8c944a4e98af233f75xxxx';
}
Note: Replace ca3-xxx.txt
with your own content, and then reload the Nginx configuration (nginx -s reload
).
Cloudflare certificate verification can be done by uploading a file or using Nginx location matching. Choose the method that you find more convenient.
I come from China and I am a freelancer. I specialize in Linux operations, PHP, Golang, and front-end development. I have developed open-source projects such as Zdir, ImgURL, CCAA, and OneNav.