Karan Adhikari commited on
Commit
09fc5b1
·
unverified ·
1 Parent(s): 8924efd

`docs(deployment)`

Browse files

replace nginx with Caddy for domain setup

Files changed (1) hide show
  1. README.md +20 -31
README.md CHANGED
@@ -330,58 +330,47 @@ Go to your domain's DNS settings and add the following **A record**:
330
 
331
  | Type | Name | Value |
332
  |------|------|-------------------|
333
- | A | @ | `195.xxx.xxx.xxx` |
334
 
335
- #### B. Install Nginx & Certbot
336
 
337
  ```bash
 
 
 
 
 
338
  sudo apt update
339
- sudo apt install nginx certbot python3-certbot-nginx -y
340
  ```
341
 
342
- #### C. Configure Nginx
343
 
344
- 1. **Create a New Nginx Config:**
345
 
346
  ```bash
347
- sudo nano /etc/nginx/sites-available/domain.com
348
  ```
349
 
350
- Paste the following (replace `domain.com` with your domain):
 
 
351
 
352
- ```nginx
353
- server {
354
- listen 80;
355
- server_name domain.com;
356
-
357
- location / {
358
- proxy_pass http://localhost:8000;
359
- proxy_set_header Host $host;
360
- proxy_set_header X-Real-IP $remote_addr;
361
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
362
- }
363
  }
364
  ```
365
 
366
- 2. **Enable the Site:**
367
 
368
- ```bash
369
- sudo ln -s /etc/nginx/sites-available/domain.com /etc/nginx/sites-enabled/domain.com
370
- ```
371
- 3. **Reload Nginx:**
372
 
373
  ```bash
374
- sudo nginx -t
375
- sudo systemctl restart nginx
376
  ```
377
 
378
 
379
- #### D. Secure with HTTPS (Let's Encrypt)
380
-
381
- ```bash
382
- sudo certbot --nginx -d domain.com
383
- ```
384
-
385
  Your API is now available at:  
386
  ➡️ `https://domain.com`
387
 
 
330
 
331
  | Type | Name | Value |
332
  |------|------|-------------------|
333
+ | A | @ | `195.xxx.xxx.xxx` |
334
 
335
+ #### B. Install Caddy
336
 
337
  ```bash
338
+ sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl
339
+ curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
340
+ curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
341
+ chmod o+r /usr/share/keyrings/caddy-stable-archive-keyring.gpg
342
+ chmod o+r /etc/apt/sources.list.d/caddy-stable.list
343
  sudo apt update
344
+ sudo apt install caddy
345
  ```
346
 
347
+ #### C. Configure Caddy
348
 
349
+ 1. **Edit the Caddyfile:**
350
 
351
  ```bash
352
+ sudo nano /etc/caddy/Caddyfile
353
  ```
354
 
355
+ Replace the contents with the following:
356
+ - Replace `domain.com` with your actual domain
357
+ - If you changed PORT in config.env from the default 8000, update the port accordingly
358
 
359
+ ```caddy
360
+ domain.com {
361
+ reverse_proxy localhost:8000
 
 
 
 
 
 
 
 
362
  }
363
  ```
364
 
365
+ Press `Ctrl + O`, then `Enter`, then `Ctrl + X` to save and exit.
366
 
367
+ 2. **Reload Caddy:**
 
 
 
368
 
369
  ```bash
370
+ sudo systemctl reload caddy
 
371
  ```
372
 
373
 
 
 
 
 
 
 
374
  Your API is now available at:  
375
  ➡️ `https://domain.com`
376