File size: 50,701 Bytes
c2df7fb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 |
Cloudflare Fundamentals What is Cloudflare? 1 min read Cloudflare is a global network of servers . When you add your application to Cloudflare, we use this network to sit in between requests and your origin server. This position allows us to do several things — speeding up content delivery and user experience ( CDN), protecting your website from malicious activity ( DDoS, Web Application Firewall), routing traffic (Load balancing, Waiting Room), and more. How Cloudflare works 3 min read Fundamentally, Cloudflare is a large network of servers that can improve the security, performance, and reliability of anything connected to the Internet. Cloudflare does this by serving as a reverse proxy for your web traffic. All requests to and from your origin flow through Cloudflare and — as these requests pass through our network — we can apply various rules and optimizations to improve security, performance, and reliability. Life of a request Even though it feels pretty instantaneous, there’s a lot happening when you type www.example.com into your browser. A website’s content does not technically live at a URL like www.example.com, but rather at an IP address like 192.0.2.1. It’s similar to how we say that Cloudflare’s headquarters is 101 Townsend St., San Francisco, CA 94107, but really that address is just a placeholder for latitude and longitude coordinates (37.780259, -122.390519). URLs and street addresses are much easier for humans to remember. The process of converting a human-readable URL (www.example.com) into a machine-friendly address (192.0.2.1) is known as a DNS lookup . Without Cloudflare Without Cloudflare, DNS lookups for your application’s URL return the IP address of your origin server . URL Returned IP address example.c 192.0.2.1 om When using Cloudflare with unproxied DNS records, DNS lookups for unproxied domains or subdomains also return your origin’s IP address. Another way of thinking about this concept is that visitors directly connect with your origin server. ConnectionVisitor Origin server With Cloudflare With Cloudflare — meaning your domain or subdomain is using proxied DNS records — DNS lookups for your application’s URL will resolve to Cloudflare Anycast IPs instead of their original DNS target. URL Returned IP address example.c 104.16.77.250 om This means that all requests intended for proxied hostnames will go to Cloudflare first and then be forwarded to your origin server. Visitor ← Connection → Cloudflare global network ←Connection→Origin Server Cloudflare assigns specific Anycast IPs to your domain dynamically and these IPs may change at any time. This is an expected part of the operation of our Anycast network and does not affect the proxy behavior described above. Benefits When your traffic is proxied through Cloudflare before reaching your origin server, your application gets additional security, performance, and reliability benefits. Security Beyond hiding your origin’s IP address from potential attackers, Cloudflare also stops malicious traffic before it reaches your origin web server. Cloudflare automatically mitigates security risks using our WAF and DDoS protection. For additional details on security, refer to our guide on how to Secure your website. Performance For proxied traffic, Cloudflare also serves as a Content Delivery Network (CDN) , caching static resources and otherwise optimizing asset delivery. For additional details on performance, refer to our guides on Optimizing Site Speed and Caching. Reliability Cloudflare’s globally distributed Anycast network routes visitor requests to the nearest Cloudflare data center. Combined together with our CDN and DDoS protection, our network helps keep your application online. Cloudflare IPs 2 min read Cloudflare has several IP address ranges which are shared by all proxied hostnames. Together, these IP addresses form the backbone of our Anycast network , helping distribute traffic amongst various edge network servers. Cloudflare uses other IP ranges for various products and services, but these addresses will not make connections to your origin. Allow Cloudflare IP addresses Because of how Cloudflare works, all traffic to proxied DNS records pass through Cloudflare before reaching your origin server. This means that your origin server will stop receiving traffic from individual visitor IP addresses and instead receive traffic from Cloudflare IP addresses , which are shared by all proxied hostnames. This setup can cause issues if your origin server blocks or rate limits connections from Cloudflare IP addresses. Because all visitor traffic will appear to come from Cloudflare IP addresses, blocking these IPs — even accidentally — will prevent visitor traffic from reaching your application. To avoid rate limiting or blocking these requests, you will need to allow Cloudflare IPs at your origin server. For Magic Transit customers, Cloudflare routes the traffic instead of proxying it. Once Cloudflare starts advertising your IP prefixes, it will accept IP packets destined for your network, process them, and then output these packets to your origin infrastructure. Customize Cloudflare IP addresses If they do not want to use Cloudflare IP addresses — which are shared by all proxied hostnames — Enterprise customers have two potential alternatives: ● Bring Your Own IP (BYOIP): Cloudflare announces your IPs in all our locations. ● Static IP addresses: Cloudflare sets static IP addresses for your domain. For more details, contact your account team. Business and Enterprise customers can also reduce the number of Cloudflare IPs that their domain shares with other Cloudflare customer domains by uploading a Custom SSL certificate. Reference architectures 1 min read Reference architecture documents and diagrams are designed to provide a foundational knowledge of Cloudflare solutioning for a variety of products. Building on the information in these documents, you can architect software solutions based on your specific context and needs. ● Content Delivery Network ● Magic Transit ● Multi-vender Application Security and Performance Account setup To create a Cloudflare account: 1. Go to the Sign up page 1. . 2. Enter your Email and Password. 3. Click Create Account. Once you create your account, Cloudflare will automatically send an email to your address to verify that email address. Best practices If you are creating an account for your team or a business, we recommend choosing an email alias or distribution list for your Email, such as [email protected]. This email address is the main point of contact for your Cloudflare billing, usage notifications, and account recovery. Set-up 2FA 2 min read Two-factor authentication (2FA) allows user account owners to add an additional layer of login security to Cloudflare accounts. This additional authentication step requires you to provide both something you know, such as a Cloudflare password, and something you have, such as an authentication code from a mobile device. Cloudflare user accounts configured to use single sign-on (SSO) cannot configure 2FA. Cloudflare offers the option to use either a phishing-resistant security key, like a YubiKey, or a Time-Based One-Time password (TOTP) mobile app for authentication, like Google Authenticator, or both. If you add both of these authentication methods to your account, you are initially prompted to log in with the security key, but can opt-out and use TOTP instead. To ensure that you can securely access your account even without your mobile device or security keys, Cloudflare also provides backup codes for download. Tip After downloading your backup codes, we recommend saving them in a secure location. As the user account owner, you are automatically assigned the Super Administrator role. Once 2FA is enabled, all Cloudflare account members are required to configure 2FA on their mobile devices. Enable 2FA We recommend that all Cloudflare user account holders enable two-factor authentication (2FA) to keep your accounts secure. 2FA can only be enabled successfully on an account with a verified email address. If you do not verify your email address first, you may lock yourself out of your account. Super Administrators can turn on 2FA Enforcement to require all members to enable 2FA. If you are not a Super Administrator, you will be forced to turn on 2FA prior to accepting the invitation to join a Cloudflare account as a member. To enable two-factor authentication for your Cloudflare login: 1. Log in to the Cloudflare dashboard 1. . 2. Under the My Profile dropdown, select My Profile. 3. Select Authentication. 4. Select Manage in the Two-Factor Authentication card. 5. Configure either a TOTP mobile app or a security key to enable 2FA on your account. Additional configurations Cloudflare also supports 2FA with device built-in authenticators (Apple Touch ID, Android fingerprint, or Windows Hello), Yubikeys and TOTP mobile applications. Customize your account 2 min read After creating an account, here are a handful of configurations you can customize: Account name Your account name defaults to <<YOUR_EMAIL_ADDRESS>>'s Account. You may want to customize the name of this account, either to help specify its purpose or to help associated with multiple accounts. To change your account name: 1. Log into the Cloudflare dashboard 1. . 2. Go to Manage Account > Configurations. 3. For Account Name, select Change Name. 4. Enter a new account name. 5. Select Save. Appearance If you want to adjust how the Cloudflare dashboard appears on your device, you can adjust relevant settings in your account Profile. To update appearance preferences: 1. Log into the Cloudflare dashboard 1. . 2. Go to My Profile 3. For Appearance, choose a value: ○ Dark: Defaults to darker colors. ○ Light: Defaults to lighter colors. ○ Use system setting: Defaults to whatever is used on your device. 4. Your dashboard display will update to the new appearance setting automatically. Communication preferences When you create an account, Cloudflare automatically chooses your Communication Preferences, or when Cloudflare might occasionally send you emails. To update the communication preferences for your profile (which requires a verified email address): 1. Log into the Cloudflare dashboard 1. . 2. Go to My Profile 3. For Communication Preferences, select Edit. 4. If you want a specific category of emails, make sure its associated box is checked. 5. Select Save. Language preferences After you create your account, you may want to update your language preference. To update the language preference for your profile: 1. Log into the Cloudflare dashboard . Go to My Profile For Language Preference, select a value. Your dashboard display will update to the new language automatically. Add and manage other members 3 min read Learn how to add new account members, edit or revoke their permissions and access, and resend verifications emails. To manage account members, you must have a role of Super Administrator and have a verified email address. View account members To manage account members, you must have a role of Super Administrator and have a verified email address. Dashboard mode: To view members using the dashboard: 1. Log in to the Cloudflare dashboard and select your account. Go to Manage Account > Members. API mode: To view members using the API, send a GET request. Baseurl: GET https://api.cloudflare.com/client/v4 An API key is a token that you provide when making API calls. Include the token in a header parameter called X-Auth-Email. Example: X-Auth-Email: 123 An API key is a token that you provide when making API calls. Include the token in a header parameter called X-Auth-Key. Example: X-Auth-Key: 123 An API key is a token that you provide when making API calls. Include the token in a header parameter called X-Auth-User-Service-Key. Example: X-Auth-User-Service-Key: 123 Provide your bearer token in the Authorization header when making requests to protected resources. Example: Authorization: Bearer 123 Interact with Cloudflare's products and services via the Cloudflare API. Using the Cloudflare API requires authentication so that Cloudflare knows who is making requests and what permissions you have. Create an API token to grant access to the API to perform actions. To create an API token, from the Cloudflare dashboard, go to My Profile > API Tokens and select Create Token. Add account members To manage account members, you must have a role of Super Administrator and have a verified email address. Dashboard mode: To add a member to your account: 1. Log in to the Cloudflare dashboard 1. and select your account. 2. Go to Manage Account > Members. 3. Select Invite. 4. Fill out the following information: ○ Invite members: Enter one or more email addresses (if multiple, separate addresses with commas). ○ Scope: Use a variety of fields to adjust the scope of your roles. ○ Roles: Choose one or more roles to assign your members. 5. Select Continue to summary. 6. Review the information, then select Invite. If a user already has an account with Cloudflare and you have an Enterprise account, you can also select Direct Add to add them to your account without sending an email invitation. API mode: POST https://api.cloudflare.com/client/v4/accounts/{account_identifier}/members Request Sample curl --request POST \ --url https://api.cloudflare.com/client/v4/accounts/account_identifier/members \ --header 'Content-Type: application/json' \ --header 'X-Auth-Email: ' \ --data '{ "email": "[email protected]", "roles": [ "3536bcfad5faccb999b47003c79917fb" ], "status": "pending" }' Response Example { "errors": [], "messages": [], "result": { "id": "4536bcfad5faccb111b47003c79917fa", "roles": [ { "description": "Administrative access to the entire Account", "id": "3536bcfad5faccb999b47003c79917fb", "name": "Account Administrator", "permissions": { "analytics": { "read": true, "write": false }, "zones": { "read": true, "write": true } } } ], "status": null, "user": { "email": "[email protected]", "first_name": "John", "id": "023e105f4ecef8ad9ca31a8372d0c353", "last_name": "Appleseed", "two_factor_authentication_enabled": false }, "code": "05dd05cce12bbed97c0d87cd78e89bc2fd41a6cee72f27f6fc84af2e45c0fac0" }, "success": true } Resend an invitation If you invited a member to your account but they cannot find the invitation or the invitation expires, you can resend the invitation through the Cloudflare dashboard: 1. Log in to the Cloudflare dashboard and select your account[^1]. 2. Go to Manage Account > Members. 3. Select a member record where their Status is Invite Pending. 4. Select Resend invite Create an API token 2 min read Prerequisite Before you begin, find your zone and account IDs. 1. From the Cloudflare dashboard, go to My Profile > API Tokens. 2. Select Create Token. 3. Select a template from the available API token templates or create a custom token. We use the Edit zone DNS template in the following examples. 4. Add or edit the token name to describe why or how the token is used. Templates are prefilled with a token name and permissions. 5. Modify the token’s permissions. After selecting a permissions group (Account, User, or Zone), choose what level of access to grant the token. Most groups offer Edit or Read options. Edit is full CRUDL (create, read, update, delete, list) access, while Read is the read permission and list where appropriate. Refer to the available token permissions for more information. 6. Select which resources the token is authorized to access. For example, granting Zone DNS Read access to a zone example.com will allow the token to read DNS records only for that specific zone. Any other zone will return an error for DNS record reads operations. Any other operation on that zone will also return an error. 7. (Optional) Restrict how a token is used in the Client IP Address Filtering and TTL (time to live) fields. 8. Select Continue to summary. 9. Review the token summary. Select Edit token to make adjustments. You can also edit a token after creation. 10. Select Create Token to generate the token’s secret. 11. Copy the secret to a secure place. Warning The token secret is only shown once. Do not store the secret in plaintext where others can access it. Anyone with this token can perform the authorized actions against the resources that the token has access to. The token secret page also includes an example command to test the token. Use the /user/tokens/verify endpoint to fetch the current status of the given token. $ curl "https://api.cloudflare.com/client/v4/user/tokens/verify" \ -H "Authorization: Bearer <API_TOKEN>" The result: { "result": { "id": "100bf38cc8393103870917dd535e0628", "status": "active" }, "success": true, "errors": [], "messages": [ { "code": 10000, "message": "This API Token is valid and active", "type": null } ] } With this you have successfully created an API token and can start working with the Cloudflare API. After creating your first API token, you can create additional API tokens via the API. Add your domain to Cloudflare Minimize downtime 2 min read When making any change to the routing of an Internet application, there is always a possibility of downtime due to certificate issuance, misconfigured settings, or limitations at your origin server. To avoid downtime when going live, it’s important to review the most common configurations. Update and review DNS records. Before activating your domain on Cloudflare (exact steps depend on your DNS setup), review the DNS records in your Cloudflare account. Start with unproxied records With a new domain, make sure all your DNS records have a proxy status of DNS-only. This setting prevents Cloudflare from proxying your traffic before you have an active edge certificate or before you have allowed Cloudflare IP addresses. Confirm record accuracy Take extra time to confirm the accuracy of your DNS records before activating your domain, paying special attention to: ● Zone apex records (example.com) ● Subdomain records (www.example.com or blog.example.com) ● Email records If you add DNS records to your authoritative DNS provider between onboarding your domain and activating your domain, you may need to also add these records within Cloudflare. Activate your domain. Finish the DNS setup for your domain, moving the domain status to Active: ● Full setups: Update the authoritative nameservers at your registrar and wait for that change to be authenticated. ● Partial setups: Add the verification TXT record to your authoritative DNS and wait for that change to be authenticated. Verify SSL/TLS edge certificates. Before proxying your traffic through Cloudflare, verify that Cloudflare has an active Edge Certificate for your domain. For more details about timing and certificate recommendations, refer to Certificate issuance. Optional - Test configuration. You may want to test your configuration using your local machine or proxying traffic from a development domain or subdomain. If you experience issues, you should make sure that you have allowed Cloudflare IP addresses at your origin server. Update proxy status. Once you have verified that your SSL/TLS edge certificate is active and you have allowed Cloudflare IP addresses, change the proxy status of appropriate DNS records to Proxied. Allow Cloudflare IP addresses 2 min read Because of how Cloudflare works, all traffic to proxied DNS records pass through Cloudflare before reaching your origin server. This means that your origin server will stop receiving traffic from individual visitor IP addresses and instead receive traffic from Cloudflare IP addresses , which are shared by all proxied hostnames. This setup can cause issues if your origin server blocks or rate limits connections from Cloudflare IP addresses. Because all visitor traffic will appear to come from Cloudflare IP addresses, blocking these IPs — even accidentally — will prevent visitor traffic from reaching your application. To avoid rate limiting or blocking these requests, you will need to allow Cloudflare IPs at your origin server. For Magic Transit customers, Cloudflare routes the traffic instead of proxying it. Once Cloudflare starts advertising your IP prefixes, it will accept IP packets destined for your network, process them, and then output these packets to your origin infrastructure. Review external tools To avoid blocking Cloudflare IP addresses unintentionally, review your external tools to check that: ● Any security plugins — such as those for WordPress — allow Cloudflare IP addresses. ● The mod_security ● plugin is up to date. Configure origin server Allowlist Cloudflare IP addresses To avoid blocking Cloudflare IP addresses unintentionally, you also want to allow Cloudflare IP addresses at your origin web server. You can explicitly allow these IP addresses with a .htaccess file or by using iptables. The following example demonstrates how your could use an iptables rule to allow a Cloudflare IP address range. Replace $ip below with one of the Cloudflare IP address ranges # For IPv4 addresses iptables -I INPUT -p tcp -m multiport --dports http,https -s $ip -j ACCEPT # For IPv6 addresses ip6tables -I INPUT -p tcp -m multiport --dports http,https -s $ip -j ACCEPT Block other IP addresses (recommended) As a best practice, we also recommend that you explicitly block all traffic that does not come from Cloudflare IP addresses or the IP addresses of your trusted partners, vendors, or applications. For example, you might update your iptables with the following commands: #for IPv4 iptables -A INPUT -p tcp -m multiport --dports http,https -j DROP #for IPv6 ip6tables -A INPUT -p tcp -m multiport --dports http,https -j DROP Disable DNSSEC 2 min read DNS Security Extensions (DNSSEC) adds an extra layer of authentication to DNS, ensuring requests are not routed to a spoofed domain. Disable DNSSEC If you are onboarding an existing domain to Cloudflare, make sure DNSSEC is disabled at your registrar (where you purchased your domain name). Otherwise, your domain will experience connectivity errors when you change your nameservers. Why do I have to disable DNSSEC? When your domain has DNSSEC enabled, your DNS provider digitally signs all your DNS records. This action prevents anyone else from issuing false DNS records on your behalf and redirecting traffic intended for your domain. However, having a single set of signed records also prevents Cloudflare from issuing new DNS records on your behalf (which is part of using Cloudflare for your authoritative nameservers). So if you change your nameservers without disabling DNSSEC, DNSSEC will prevent Cloudflare’s DNS records from resolving properly. Add a site 2 min read 1. Log in to the Cloudflare dashboard. 2. In the top navigation bar, click Add site. 3. Enter your website’s apex domain (example.com) and then click Add Site. If Cloudflare is unable to identify your domain as a registered domain, make sure you are using an existing top-level domain (.com, .net, .biz, or others). Additionally, Cloudflare requires your apex domain to be one level below a valid TLD defined in the Public Suffix List (PSL). 1. Select your plan level. For more details on features and pricing, refer to our Plans page . 2. Review your DNS records. When you add a new site to Cloudflare, Cloudflare automatically scans for common records and adds them to the DNS zone. The records show up under the respective zone DNS > Records page. 3. Since this scan is not guaranteed to find all existing DNS records, you need to review your records, paying special attention to the following record types: a. Zone apex records (example.com) b. Subdomain records (www.example.com or blog.example.com) c. Email records 4. If you activate your domain on Cloudflare without setting up the correct DNS records for your domain and subdomain, your visitors may experience DNS_PROBE_FINISHED_NXDOMAIN errors. 5. If you find any missing records, manually add those records. 6. Depending on your site setup, you may want to adjust the proxy status for certain A, AAAA, or CNAME records. 7. Click Continue. 8. Go through the Quick Start Guide and when you have finished, click Finish. Update your nameservers 1 min read Once you have added a domain (also known as a zone) to Cloudflare, that domain will receive two assigned authoritative nameservers. Before your domain can begin using Cloudflare for DNS resolution, you need to add these nameservers at your registrar. Make sure DNSSEC is disabled at this point. Domain Resolution Ensure all your traffic is proxying through Cloudflare successfully. Objectives By the end of this module, you will be able to: ● Confirm your zone is set up correctly on Cloudflare ● Recognize and troubleshoot issues with your DNS records and SSL/TLS certificates Review DNS records 1 min read When you add a new site to Cloudflare, Cloudflare automatically scans for common records and adds them to the DNS zone. The records show up under the respective zone DNS > Records page. The DNS records quick scan is not automatically invoked in the following cases: ● If you choose Enterprise plan and, instead of the Quick Scan, choose to upload a DNS zone file or add records manually. ● If you add a zone via the API. You can manually invoke the quick scan via API with the Scan DNS Records endpoint. Note that the quick scan is a best effort attempt based on a predefined list of commonly used record names and types. You can read more about this in the reference page. Since this scan is not guaranteed to find all existing DNS records, you need to review your records, paying special attention to the following record types: ● Zone apex records (example.com) ● Subdomain records (www.example.com or blog.example.com) ● Email records If you want more control over which DNS records are imported and how, import a zone file. If your domain is added to Cloudflare by a hosting partner, manage your DNS records via the hosting partner. Proxy status 3 min read The Proxy status of a DNS record affects how Cloudflare treats incoming traffic to that record. Cloudflare recommends enabling our proxy for all A, AAAA, and CNAME records. Proxied records Note that if you have multiple A/AAAA records on the same name and at least one of them is proxied, Cloudflare will treat all A/AAAA records on this name as being proxied. When you proxy specific DNS records through Cloudflare - specifically A, AAAA, or CNAME records — DNS queries for these will resolve to Cloudflare Anycast IPs instead of their original DNS target. This means that all requests intended for proxied hostnames will go to Cloudflare first and then be forwarded to your origin server. This behavior allows Cloudflare to optimize, cache, and protect all requests to your application, as well as protect your origin server from DDoS attacks Because requests to proxied hostnames go through Cloudflare before reaching your origin server, all requests will appear to be coming from Cloudflare’s IP addresses (and could potentially be blocked or rate limited). If you use proxied records, you may need to adjust your server configuration to allow Cloudflare IPs. Cloudflare Anycast IPs used to proxy traffic on your domain are assigned automatically. These IPs might change at any time for operational reasons. If you need to allowlist Cloudflare IPs on your infrastructure or hosting provider, include the full list of Cloudflare Anycast IPs As an Enterprise customer, you have the option to get static IPs or bring your own IPs (BYOIP). Limitations Record types By default, Cloudflare only supports proxied A, AAAA, and CNAME records. You cannot proxy other record types. If you encounter a CNAME record that you cannot proxy — usually associated with another CDN provider — a proxied version of that record will cause connectivity errors. Cloudflare is purposely preventing that record from being proxied to protect you from a misconfiguration. Ports and protocols By default, Cloudflare only proxies HTTP and HTTPS traffic. If you need to connect to your origin using a non-HTTP protocol (SSH, FTP, SMTP) or the traffic targets an unsupported port at the origin, either leave your records unproxied (DNS-only) or use Cloudflare Spectrum. Pending domains When you add a domain to Cloudflare, Cloudflare protection will be in a pending state until we can verify ownership. This could take up to 24 hours to complete. This means that DNS records - even those set to proxy traffic through Cloudflare – will be DNS-only until your zone has been activated and any requests to your DNS records will return your origin server’s IP address. If this warning is still present after 24 hours, refer to Troubleshooting. For enhanced security, we recommend rolling your origin IP addresses at your hosting provider after your zone has been activated. This action prevents your origin IPs from being leaked during onboarding. Windows authentication Because Microsoft Integrated Windows Authentication, NTLM, and Kerberos violate HTTP/1.1 specifications, they are not compatible with proxied DNS records. Enable DNSSEC 2 min read DNS Security Extensions (DNSSEC) adds an extra layer of authentication to DNS, ensuring requests are not routed to a spoofed domain. For additional background on DNSSEC, visit the Cloudflare Learning Center . When you enable DNSSEC, Cloudflare signs your zone, publishes your public signing keys, and generates your DS record. Step 1 - Activate DNSSEC in Cloudflare 1. Log in to the Cloudflare dashboard 1. and select your account and domain. 2. Go to DNS > Settings. 3. For DNSSEC, click Enable DNSSEC. 4. In the dialog, you have access to several necessary values to help you create a DS record at your registrar. Once you close the dialog, you can access this information by clicking DS record on the DNSSEC card. Step 2 — Add DS record to your registrar Add the DS record to your registrar. If Algorithm 13 - Cloudflare’s preferred cipher choice - is not listed by your registrar, it may also be called ECDSA Curve P-256 with SHA-256. Provider-specific instructions Note: Cloudflare automatically adds DS records for domains using Cloudflare Registrar or those using .ch and .cz top-level domains. Create a subdomain 1 min read Most subdomains serve a specific purpose within the overall context of your website. For example, blog.example.com might be your blog, support.example.com could be your customer help portal, and store.example.com would be your e-commerce site. Subdomain records To create a new subdomain, you would first add the subdomain content at your host. Then, you would create a corresponding A, AAAA, or CNAME record for that subdomain (blog, store). Type Name IPv4 Proxy address status A www 192.0.2.1 Proxied Set up email records 1 min read Receive email If you only need to receive emails, Cloudflare offers Email Routing for free email forwarding to custom email addresses. Send and receive email To send and receive emails from your domain, you need: ● An SMTP provider. ● To create two DNS records within Cloudflare. To route emails through Cloudflare and to your mail server: 1. Get the IP address and MX record details from your SMTP provider (vendor-specific guidelines). 2. Add an A or AAAA record for your mail subdomain that points to the IP address of your mail server. Type Name IPv4 Proxy address status A mail 192.0.2.1 DNS only 3. API example 4. Add an MX record that points to that subdomain. Type Name Mail server TTL MX @ mail.example. Auto com API Example: Request: curl -sX POST "https://api.cloudflare.com/client/v4/zones/<ZONE_ID>/dns_records" \ -H 'x-auth-email: <EMAIL>' \ -H 'x-auth-key: <API_KEY>' \ -H "Content-Type: application/json" \ --data '{ "type":"MX", "name":"example.com", "content":"mail.example.com", "ttl":3600 }' Response: { "result": { "id": "<ID>", "zone_id": "<ZONE_ID>", "zone_name": "example.com", "name": "example.com", "type": "MX", "content": "mail.example.com", "priority": 10, "proxiable": false, "proxied": false, "ttl": 3600, "locked": false, "meta": { "auto_added": false, "managed_by_apps": false, "managed_by_argo_tunnel": false, "source": "primary" }, "comment": null, "tags": [], "created_on": "2023-01-17T20:54:23.660869Z", "modified_on": "2023-01-17T20:54:23.660869Z" }, "success": true, "errors": [], "messages": [] } Default improvements 1 min read When your DNS records are proxied through Cloudflare, Cloudflare provides free and unmetered DDoS protection and other protection measures through the Web Application Firewall (WAF). DDoS protection A distributed denial-of-service (DDoS) attack is where a large number of computers or devices, usually controlled by a single attacker, attempt to access a website or online service all at once. This flood of traffic can overwhelm the website’s origin servers, causing the site to slow down or even crash. For more information about DDoS attacks and Cloudflare DDoS protection, refer to Prevent DDoS attacks. Managed rulesets All customers have access to the Cloudflare Free Managed Ruleset, which provides mitigations against high and wide-impacting vulnerabilities. For more details, refer to the WAF documentation. SSL/TLS settings 2 min read Once you make sure that your Cloudflare SSL/TLS is working correctly, you will likely want to customize your SSL/TLS setup. Encryption mode Your zone’s SSL/TLS Encryption Mode controls how Cloudflare manages two connections: one between your visitors and Cloudflare, and the other between Cloudflare and your origin server. Basic setup The simplest way to choose your encryption mode is to enable the SSL/TLS Recommender, which scans your domain and recommends the appropriate setting. To make sure you do not inadvertently block the SSL/TLS Recommender, review your settings to make sure your domain: ● Is accessible. ● Is not blocking requests from our bot (which uses a user agent of Cloudflare-SSLDetector). ● Does not have any active, SSL-specific Page Rules or Configuration rules. Then, you can enable SSL/TLS recommendations in the dashboard: 1. Log in to the Cloudflare dashboard 1. and select your account and application. 2. Go to SSL/TLS. 3. For SSL/TLS Recommender, switch the toggle to On. Once enabled, the SSL/TLS Recommender runs an origin scan using the user agent Cloudflare-SSLDetector and ignores your robots.txt file (except for rules explicitly targeting the user agent). Based on this initial scan, the Recommender may decide that you could use a stronger SSL encryption mode. It will never recommend a weaker option than what is currently configured. If so, it will send the application owner an email with the recommended option and add a Recommended by Cloudflare tag to that option on the SSL/TLS page. You are not required to use this recommendation. If you do not receive an email, keep your current SSL encryption mode. Secure setup If possible, Cloudflare recommends using Full or Full (strict) modes to prevent malicious connections to your origin. These modes usually require additional setup and can be more technically challenging. Enforce HTTPS connections Even if your application has an active edge certificate, visitors can still access resources over unsecured HTTP connections. Using various Cloudflare settings, however, you can force all or most visitor connections to use HTTPS. Evaluate additional features After you have chosen your encryption mode and enforced HTTPS connections, evaluate the following settings: ● Edge certificates: Customize different aspects of your edge certificates, from enabling Opportunistic Encryption to specifying a Minimum TLS Version. ● Authenticated origin pull: Ensure all requests to your origin server originate from the Cloudflare network. ● Notifications: Set up alerts related to certificate validation status, issuance, deployment, renewal, and expiration. Bot Fight Mode 1 min read Bot Fight Mode is a simple, free product that helps detect and mitigate bot traffic on your domain. When enabled, the product: ● Identifies traffic matching patterns of known bots ● Issues computationally expensive challenges in response to these bots ● Notifies Bandwidth Alliance ● partners (if applicable) to disable bots Considerations Bot Fight Mode has a few limitations, including that it: ● Protects entire domains without endpoint restrictions. ● Cannot be customized, adjusted, or reconfigured via WAF custom rules. If these limitations could cause issues with your application, do not enable this feature. For more granular control - including the ability to use the Skip action for bot mitigation - consider using Super Bot Fight Mode. Setup To start using Bot Fight Mode: 1. Log in to the Cloudflare dashboard and select your account and domain. Go to Security > Bots. For Bot Fight Mode, select On. Secure your origin 4 min read Your origin server is a physical or virtual machine that is not owned by Cloudflare and hosts your application content (data, webpages, etc.). Receiving too many requests can be bad for your origin. These requests might increase latency for visitors, incur higher costs — particularly for cloud-based machines — and could knock your application offline. Secure origin connections When you secure origin connections, it prevents attackers from discovering and overloading your origin server with requests. ● DNS: 1. Proxy records (when possible): Set up proxied (orange-clouded) DNS records to hide your origin IP addresses and provide DDoS protection. As part of this, you should allow Cloudflare IP addresses at your origin to prevent requests from being blocked. 2. Review DNS-only records: Audit existing DNS-only records (SPF, TXT, and more) to make sure they do not contain origin IP information. 3. Evaluate mail infrastructure: If possible, do not host a mail service on the same server as the web resource you want to protect, since emails sent to non-existent addresses get bounced back to the attacker and reveal the mail server IP. 4. Rotate origin IPs: Once onboarded, rotate your origin IPs, as DNS records are in the public domain. Historical records are kept and would contain IP addresses prior to joining Cloudflare Application layer 1. Cloudflare Tunnel (HTTP/WebSockets) Cloudflare Tunnel connects your resources to Cloudflare without a publicly routable IP address, by creating an outbound-only connections to Cloudflare’s global network. ● Security: Very secure. ● Availability: All customers. ● Challenges: Requires installing the cloudflared daemon on origin server or virtual machine. 2. HTTP Header Validation Only allow traffic with specific (and secret) HTTP headers. ● Security: Moderately secure. ● Availability: All customers. ● Challenges: 1. Requires more configuration efforts on application- and server-side to accept those headers. 2. Basic authentication is vulnerable to replay attacks. Because basic authentication does not encrypt user credentials, it is important that traffic always be sent over an encrypted SSL session. 3. There might be valid use cases for a mismatch in SNI / Host headers such as through Page Rules, Load Balancing, or Workers, which all offer HTTP Host Header overrides. ● Process: 1. Use Transform rules or Workers to add an HTTP Auth Header. 2. Configure your origin server to restrict access based on the HTTP Auth Header (or perform HTTP Basic Authentication). 3. Configure your origin server to restrict access based on the HTTP Host Header. Specifically, only allow requests which contain expected HTTP Host Header values, and reject all other requests. 3. JSON Web Tokens (JWT) Validation Only allow traffic with the appropriate JWT. ● Security: Very secure. ● Availability: Some customers. ● Challenges: ○ Requires either installing incremental software or modifying application code. ○ Lots of manual work. ● Resources: ○ Validate JWTs for an Access application ○ Validate JWTs for an API Transport Layer Authenticated Origin Pulls Authenticated Origin Pulls helps ensure requests to your origin server come from the Cloudflare network. ● Security: Very secure. ● Availability: All customers. ● Challenges: ○ Requires Full or Full (strict) encryption modes. ○ Requires more configuration efforts for application and server, such as uploading a certificate and configuring the server to use it. ○ For more strict security, you should upload your own certificate. Although Cloudflare provides you a certificate for easy configuration, this certificate only guarantees that a request is coming from the Cloudflare network. ○ Not scalable for large numbers of origin servers. Cloudflare Tunnel (SSH / RDP) Cloudflare Tunnel connects your resources to Cloudflare without a publicly routable IP address, by creating an outbound-only connections to Cloudflare’s global network. ● Security: Very secure. ● Availability: All customers. ● Challenges: Requires installing the cloudflared daemon on origin server or virtual machine. Network Layer Allowlist Cloudflare IP addresses Explicitly block all traffic that does not come from Cloudflare IP addresses (or the IP addresses of your trusted partners, vendors, or applications). ● Security: Moderately secure. ● Availability: All customers. ● Challenges: ○ Requires allowlisting Cloudflare IP ranges at your origin server. ○ Vulnerable to IP spoofing. Cloudflare Network Interconnect Cloudflare Network Interconnect allows you to connect your network infrastructure directly with Cloudflare – rather than using the public Internet – for a more reliable and secure experience. ● Security: Very secure. ● Availability: Enterprise-only. ● Challenges ○ Requires some networking knowledge. ○ Only applies to some customer use cases. Cloudflare Aegis Cloudflare Aegis prevents external connections by providing dedicated egress IP addresses. ● Security: Very secure. ● Availability: Enterprise-only. ● Challenges: Requires network-level firewall policies. Security Center 1 min read Cloudflare Security Center brings together our suite of security products, our security expertise, and unique Internet intelligence as a unified security intelligence solution. Security Center enables you to strengthen your security posture by: ● Mapping your cyber attack surface ● Providing asset inventory and discovery ● Identifying potential security risks, misconfigurations, and vulnerabilities ● Helping you to mitigate these risks through remediation in a few clicks For additional details and help, refer to the Security Center documentation. Setup To enable Security Insights and perform an initial security scan: 1. Log in to the Cloudflare dashboard 1. and select your account. 2. In the Account Home, go to Security Center > Security Insights. 3. Under Enable Security Center scans, select Start scan. The initial Security Insights scan will start. The initial scan time depends on the number of IT assets in all the domains of your Cloudflare account. When the scan is complete, the status of the page will change from Scan in Progress to Last scan performed on: <DATE_TIME>. Performance Improve your application’s performance by enabling and optimizing your sites settings. Objectives By the end of this module, you will be able to: ● Explain how - just by using Cloudflare - you can increase application performance ● Optimize caching using various Cloudflare settings ● Improve performance using different settings within Speed settings ● Set up Cloudflare Web Analytics for free, privacy-first analytics ● Evaluate other, add-on products that can improve application performance Default improvements 1 min read Cloudflare provides a variety of speed improvements by default. DNS resolution When your site is using Cloudflare, your site always benefits from Cloudflare’s lightning-fast DNS resolution . Caching When your DNS records are proxied through Cloudflare, Cloudflare caches certain types of resources automatically (which improves application performance). How does caching improve performance? Caching is the process of storing copies of files in a cache, or temporary storage location, so that they can be accessed more quickly. When Cloudflare stores content in its cache, the request never needs to go to your application or origin server, which reduces the number of requests and gets content to the user more quickly. Optimize caching 1 min read Beyond default caching settings, you can further optimize your cache using different Cloudflare settings. A few ways to optimize Cloudflare caching include: ● Creating cache rules to customize the cache properties of specific HTTP requests. ● Enabling the Tiered Cache feature, which dramatically increases cache hit ratios. ● Reviewing our other various configuration options, which may vary based on your plan and application setup. Optimize analytics 2 min read Web analytics let you measure user behavior - pageviews, sessions, and custom events - on your application. Cloudflare offers two ways to improve the privacy and performance of the way you gather these analytics. Cloudflare Web Analytics If you want analytics without using third-party tools, check out Cloudflare Web Analytics. Cloudflare Web Analytics provides free, privacy-first analytics for your website without changing your DNS or using Cloudflare’s proxy. Cloudflare Web Analytics helps you understand the performance of your web pages as experienced by your site visitors. All you need to enable Cloudflare Web Analytics is a Cloudflare account and a JavaScript snippet on your page to start getting information on page views and visitors. The JavaScript snippet (also known as a beacon) collects metrics using the Performance API, which is available in all major web browsers. Setup So long as your traffic is proxied through Cloudflare, setting up Web Analytics only involves a few steps: 1. Log in to the Cloudflare dashboard 1. , and select your account. 2. Select the Analytics & Logs drop-down and choose Web Analytics. 3. Under Quick Actions, select Add a site. 4. Select a hostname from the drop-down menu > Done. Access Once you have enabled Web Analytics, you can review analytics at any time: 1. Log in to the Cloudflare dashboard 1. , and select your account. 2. Select the Analytics & Logs drop-down and choose Web Analytics. 3. Select your zone. 4. Review the various metrics provided by Cloudflare. Notifications Web Analytics uses Cloudflare’s Notification service. When enabled, Web Analytics sends you a weekly report with aggregate visits, page views and median page load time for all your sites, so you can monitor their performance. To get started, add Web Analytics notification on your Cloudflare dashboard. Refer to Cloudflare Notifications to learn more. Cloudflare Zaraz If you already use third-party tools on your website, check out Cloudflare Zaraz. Cloudflare Zaraz gives you complete control over third-party tools and services for your website, and allows you to offload them to Cloudflare’s edge, improving the speed and security of your website. With Cloudflare Zaraz you can load tools such as analytics tools, advertising pixels and scripts, chatbots, marketing automation tools, and more, in the most optimized way. Cloudflare Zaraz is built for speed, privacy, and security, and you can use it to load as many tools as you need, with a near-zero performance hit. |