Custom Domain (API)
:::highlight yellow 💡
Having issues understanding the documentation? Watch our tutorial
:::
Overview
Some internet service providers (ISP) block requests to our API. One way to get around this is to use a vpn, of course this may not be the ideal for a lot of users, this is where custom domains come into place. A custom domain will allow you to point your own URL to our API and make requests that way.
Getting Started
Obtaining A Domain
First, you will want to get a domain. You can get a free one from sites such as freenom.
Setting Up Cloudflare
- Log into your CloudFlare account.
- Select a website, if you do not have one please follow the steps provided by CloudFlare to create one.
- Click on "DNS" on the left sidebar to open the DNS page.
Now that we are on the DNS page, you want to click on "Add Record". You want to make sure of the following:
- Type = "CNAME"
- Name = The name of the subdomain that you want. If you want the main domain, you would put "@", or you can put something like "api".
- Target = "api.keyauth.win"
- Proxied Status = Proxied (should be orange)
- Press save
That's all you have to do on the DNS page. Now, we will want to head over to the "SSL/TLS" page, on the left sidebar.
SSL/TLS Page
Once you're there, you're going to want to make sure that the SSL/TLS encryption mode is set to "Flexible".
Now, head over to "Edge Certificates", this is located under the "SSL/TLS" tab on the left sidebar.
You are going to want to make sure "Always Use HTTPS" is ENABLED.
Now, head over to the "Security" tab on the left sidebar, and click on "WAF".
Security / WAF Page
Click on "+ Create Rule".
Set a rule name, this can be anything you want.
Then, for the incoming requests, put either of the following:
Using Python?
Python Setup | ||
---|---|---|
Field | Operator | Value |
User Agent | contains | requests-requests |
Using New Example?
New Example Setup | ||
---|---|---|
Field | Operator | Value |
User Agent | does not equal | LEAVE BLANK |
Using Older Example?
Older Example Setup | ||
---|---|---|
Field | Operator | Value |
User Agent | does not equal | KeyAuth |
REDARDLESS OF WHICH ONE YOU SELECT, IF YOU ARE USING IT FOR MORE THAN JUST THE API (MEANING YOU ALSO HAVE ACTIVE CONTENT ON YOUR WEBSITE YOU MUST DO THE FOLLOWING
Click on "AND", next to the field you entered, then put:
Using Older Example?
Heading | ||
---|---|---|
Field | Operator | Value |
Hostname | equals | The name of your subname you set in your DNS settings |
Then, head over to the DDoS page, under Security:
Security / DDoS Page
You will want to configure it, and set the "Ruleset sensitivity" to "High".
Now head over to the Settings page, under Security:
Security / Settings Page
Disable "Browser Integrity Check
Set "Security Level" to "Essentially Off"
Test It Out
Open up command prompt on your device and type in,
curl https://yourwebsite.ext/1.0/ -H "user-agent:"
or if you put "api" in the root name, it would be
curl https://yourwebsite.ext/api/1.0/ -H "user-agent:"
If you set it up correctly, you should see:
{"success":false, "message":"Unhandled Type"}
Changing The Url In Your Application
Lastly, head over to our API class in your application, and search for "https://keyauth.win/api/1.2/", you will want to replace this with your new URL.