Skip to content

Commit ea438dc

Browse files
committed
docs: how to use section
1 parent 27b5639 commit ea438dc

File tree

2 files changed

+73
-13
lines changed

2 files changed

+73
-13
lines changed

CONTRIBUTING.md

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
11
# Contributing
22

3-
## Branch Naming
4-
5-
```text
6-
type/humanFriendlyDescription
7-
```
8-
9-
Example:
10-
11-
```text
12-
chore/upgradeLodashToLatestVersion
13-
```
14-
153
## Commit Format
164

175
Commit message is validated with

README.md

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Use this worker to password-protect whole websites or some areas/specific pages.
44

5-
E.g. limit access to a staging version of a static website you're building.
5+
_E.g. limit access to a staging version of a website you're building._
66

77
## Demo
88

@@ -15,6 +15,78 @@ User name: `demouser`
1515

1616
Password: `demopassword`
1717

18+
## How to use
19+
20+
Requirements:
21+
22+
- your website's DNS is managed by Cloudflare
23+
- corresponding DNS record is proxied (orange cloud)
24+
25+
In order to protect your website with this worker you will
26+
need to deploy worker code and configure route mapping.
27+
There are multiple ways you can deploy workers, here are couple options for your
28+
consideration.
29+
30+
### Option #1. Deploy manually via CF dashboard
31+
32+
If you care about _Infrastructure as Code_, skip to Option #2.
33+
34+
Create a worker.
35+
36+
- Go to Cloudflare Dashboard / Account Home / `Workers`
37+
- `Create a Worker`
38+
- Paste the code
39+
- `Save and Deploy`
40+
41+
Configure route mapping.
42+
43+
- Go to Account Home / Domain / `Workers`
44+
- `Add route`
45+
- Provide route, e.g. example.com/protected/\*
46+
- Select worker
47+
- `Save`
48+
49+
You're set! If you open `example.com/protected/anything` now it will prompt you
50+
to enter password.
51+
52+
### Option #2. Deploy with Wrangler
53+
54+
Wrangler is a tool built by Cloudflare to develop, test and deploy workers code.
55+
For more thorough overview, check
56+
[documentation](https://developers.cloudflare.com/workers/quickstart).
57+
58+
First you need to collect some information from your CF account.
59+
60+
- Account ID.
61+
- Account Home / Domain / `Overview` tab / `API` section / `Account ID`
62+
- Zone ID.
63+
- Account Home / Domain / `Overview` tab / `API` section / `Zone ID`
64+
- API token.
65+
- Account Home / Domain / `Overview` tab / `API` section / `Get API Token`
66+
- `Create Token`
67+
- `Start with Template`
68+
- Select the `Edit Cloudflare Workers` template
69+
- `Continue to Summary`
70+
- `Create Token`
71+
72+
Install Wrangler. `npm install -g @cloudflare/wrangler`
73+
74+
Create Wrangler config. `wrangler init --type javascript`
75+
76+
Update Wrangler config. Example:
77+
78+
```
79+
name = "cf-worker-basic-http-auth"
80+
type = "javascript"
81+
account_id = "<YOUR ACCOUNT ID>"
82+
zone_id = "<YOUR ZONE ID>"
83+
route = "example.com/protected/*"
84+
```
85+
86+
Configure API token. `wrangler config`
87+
88+
Deploy worker. `wrangler publish`
89+
1890
## Contributing
1991

2092
see [CONTRIBUTING.md](CONTRIBUTING.md)

0 commit comments

Comments
 (0)