-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcloudflare.com
More file actions
364 lines (197 loc) · 6.82 KB
/
cloudflare.com
File metadata and controls
364 lines (197 loc) · 6.82 KB
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
Step 1: Create Cloudflare Origin Certificate
In Cloudflare Dashboard:
Go to your domain
SSL/TLS menu
Origin Server
Create Certificate
Choose settings:
Private Key type: RSA
Validity: 15 years
Copy:
Certificate
Private Key
Step 2: Upload certs to ERPNext server
SSH into your ERPNext server.
Create certificate directory:
sudo mkdir -p /etc/nginx/ssl/erpnext
Create certificate file:
sudo nano /etc/nginx/ssl/erpnext/origin.crt
Paste Cloudflare Origin Certificate, save.
Create private key file:
sudo nano /etc/nginx/ssl/erpnext/origin.key
Paste Cloudflare Private Key, save.
Set permissions:
sudo chmod 600 /etc/nginx/ssl/erpnext/origin.key
sudo chmod 644 /etc/nginx/ssl/erpnext/origin.crt
Step 3: Modify bench Nginx config
Find your ERPNext site Nginx file (example):
cd /etc/nginx/conf.d/
Or sometimes:
cd /etc/nginx/sites-available/
Open the site config, example:
sudo nano /etc/nginx/conf.d/frappe-bench.conf
Find the HTTPS server block and replace SSL lines to:
ssl_certificate /etc/nginx/ssl/erpnext/origin.crt;
ssl_certificate_key /etc/nginx/ssl/erpnext/origin.key;
ssl_session_timeout 1d;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
Save the file.
Step 4: Restart bench and Nginx
sudo bench setup nginx
sudo service nginx reload
sudo service nginx restart
sudo supervisorctl restart all
Double-check nginx syntax:
sudo nginx -t
Step 5: Cloudflare security settings
In Cloudflare dashboard:
Setting Value
SSL Mode Full (strict)
Always Use HTTPS Enabled
HSTS Enabled
Proxy (orange cloud) Enabled
Disable Flexible SSL Yes
Browser cache TTL Recommended default
Rocket Loader Off for ERPNext (optional)
Also go to Firewall rules and restrict direct IP access later.
Step 6: Restrict server access to Cloudflare IPs only (Important)
Edit firewall:
sudo ufw allow ssh
sudo ufw enable
Allow Cloudflare IP ranges only for HTTP/HTTPS:
Download Cloudflare IP list:
curl https://www.cloudflare.com/ips-v4 -o ips-v4.txt
curl https://www.cloudflare.com/ips-v6 -o ips-v6.txt
Loop add rules:
for ip in $(cat ips-v4.txt); do sudo ufw allow from $ip to any port 443 proto tcp; done
for ip in $(cat ips-v6.txt); do sudo ufw allow from $ip to any port 443 proto tcp; done
Block other access:
sudo ufw deny 80
sudo ufw deny 443
This ensures traffic only passes through Cloudflare.
Verification checklist
Check Command
Nginx certificate active curl -v https://yourdomain.com
Cloudflare SSL mode Full strict
Origin HTTP access blocked curl http://server-ip should fail
Browser padlock Secured
ERPNext working Login test
🎯 Result
You now have:
Cloudflare edge TLS
Origin TLS with long-life cert
DDoS and WAF protection
Zero Let's Encrypt renewal headaches
ERPNext safe from direct hits
Good move for production ERPNext.
ood setup for you
Frappe/ERPNext server certificate: Let's Encrypt
Cloudflare: Full (strict) SSL mode
Cloudflare proxied DNS (orange cloud)
This gives you secure browser → Cloudflare → ERPNext encryption.
✅ What to check
Go to Cloudflare dashboard > SSL/TLS settings
Make sure:
Setting Value
SSL Mode Full (strict)
Always use HTTPS Enabled
Minimum TLS TLS 1.2 or higher
Do not use "Flexible SSL" because it breaks ERPNext and is less secure.
✅ Small compatibility note
Sometimes Cloudflare security features can block ERPNext background jobs or API calls. If you see strange login or websocket issues, set:
Firewall > Bot Fight Mode → Off (optional for ERPNext)
Speed > Rocket Loader → Off
Those avoid conflicts with Frappe's JS and sockets.
👍 You're good to continue
Let's Encrypt is strong, compatible, and safe. No need to change unless you want long-term certificates later.
You made a solid decision to keep your setup simple and secure.
✅ Quick checklist for safest configuration
Inside Cloudflare Dashboard:
Setting Value
SSL Mode Full (strict)
Always Use HTTPS ON
HSTS ON (after testing)
Automatic HTTPS rewrites ON
Rocket Loader OFF (ERPNext compatibility)
Bot Fight Mode OFF (optional)
✅ Step 1: Check browser HTTPS lock
Open your site:
https://oropendola.ai
Verify:
✅ Padlock icon is visible
✅ No certificate warnings
✅ Certificate issued by Let’s Encrypt
Click the padlock → “Connection is secure” → “Certificate” to confirm.
✅ Step 2: Check Cloudflare SSL mode
Go to Cloudflare dashboard:
SSL/TLS → Overview
Verify it shows:
✅ Full (strict)
If it says “Flexible”, change it immediately. Frappe will break.
✅ Step 3: Confirm Cloudflare is proxying
Go to DNS in Cloudflare.
Your A record for the domain should show:
Orange cloud ✅ (Proxied)
Not grey cloud ❌
✅ Step 4: Terminal check from your server
SSH into your ERPNext server and run:
curl -I https://yourdomain.com
Expected output contains:
HTTP/2 200
server: nginx
cf-ray: ... Cloudflare header ...
Key point: cf-ray means Cloudflare is active.
✅ Step 5: Test origin SSL directly (optional but strong test)
Run on your server:
openssl s_client -connect yourdomain.com:443 -servername yourdomain.com
Look for:
issuer=Let's Encrypt
Verify return code: 0 (ok)
That confirms your Let's Encrypt cert is valid and live.
✅ Step 6: Confirm WebSockets working
In ERPNext, open Desk → Console → Watch browser dev tools.
Press F12 → Network tab → WS filter
Check socket.io connection status shows:
✅ 101 Switching Protocols
✅ No continuous reconnects
If you see 400/403/502, tell me and I will fix it for you.
✅ Step 7: Test direct server IP blocked (security)
Visit your server IP in browser:
http://your.server.ip
You want to see:
❌ Not opening ERPNext login page
✅ Blocked / timed out / Cloudflare error / default page
This confirms no one can bypass Cloudflare.
✅ Step 2: Allow only Cloudflare IPs to reach your server
Run on Ubuntu:
sudo ufw allow ssh
sudo ufw deny http
sudo ufw deny https
Then add Cloudflare IP ranges:
IPv4
for ip in $(curl https://www.cloudflare.com/ips-v4); do sudo ufw allow from $ip to any port 443 proto tcp; done
for ip in $(curl https://www.cloudflare.com/ips-v4); do sudo ufw allow from $ip to any port 80 proto tcp; done
IPv6 (if you use IPv6)
for ip in $(curl https://www.cloudflare.com/ips-v6); do sudo ufw allow from $ip to any port 443 proto tcp; done
for ip in $(curl https://www.cloudflare.com/ips-v6); do sudo ufw allow from $ip to any port 80 proto tcp; done
Enable firewall:
sudo ufw enable
sudo ufw status
✅ Step 3: Cloudflare settings for ERPNext
Inside Cloudflare Dashboard → Rules → Security
Setting Value
WAF ON
Security Level Medium or High
Bot Protection Standard
Browser Integrity Check ON
DDoS Attack Mode Auto
Firewall rules to add
Block direct access by IP:
Rule:
(http.host eq "your-server-ip")
Action: Block
Block admin brute force:
(http.request.uri.path contains "/login") or (http.request.uri.path contains "/desk")
Action: Challenge (JS Challenge)
https://oropendola.ai/ site not reaching