|
1 | 1 | # Runbook: Nginx debugging
|
2 | 2 |
|
| 3 | +## Local curl |
| 4 | + |
| 5 | +Use `--connect-to` to bypass any CDN and test the origin directly. |
| 6 | + |
| 7 | +``` |
| 8 | +you@laptop$ curl -I 'https://view.jquery.com/bar' --connect-to '::miscweb-01.ops.jquery.net' |
| 9 | +``` |
| 10 | + |
| 11 | +You can also do this from the origin itself over SSH |
| 12 | + |
| 13 | +``` |
| 14 | +krinkle@miscweb-01:~$ curl -v -I 'https://view.jquery.com/bar' --connect-to ::localhost |
| 15 | +``` |
| 16 | + |
3 | 17 | ## Staging and testing
|
4 | 18 |
|
5 |
| -* Push to `puppet-stage`. |
6 |
| -* Apply on **wp-01.stage**.ops by running `sudo puppet agent -tv` there. |
| 19 | +For nginx changes to WordPress hosts, you can use staging: |
| 20 | + |
| 21 | +* Push edits to `staging` branch. |
| 22 | +* SSH to a stage host (e.g. **wp-03.stage**.ops) and run `sudo run-puppet-agent` there. |
7 | 23 | * If there are errors, especially the `Nginx[refresh]` line, then stop and fix the patch.
|
8 | 24 | * To get more details on the error, use `sudo service nginx configtest` and `sudo nginx -t`.
|
9 |
| -* Push to `puppet-master`. |
10 |
| -* Apply on `wp-02.ops` by running `sudo puppet agent -tv` there. Confirm content sites (besides releases/codeorigin) are fine. |
11 |
| -* Apply on `wp-03.ops` by running `sudo puppet agent -tv` there. Confirm codeorigin is fine. |
| 25 | +* Once happy, forward to `production`. |
| 26 | +* Apply on relevant prod (e.g. wp-05 for jqueryui, wp-04 for jquery) by running `sudo run-puppet-agent` there and confirming the behaviour afterwards. Use local curl (example below) instead of the public Clouflare-cached URL if caching might be at play. |
12 | 27 |
|
13 | 28 | ## Live hacking
|
14 | 29 |
|
15 |
| -To test and **debug Nginx changes** for jQuery content sites hosted on wp-01, wp-02, or wp03. |
| 30 | +Sometimes iterating through the staging branch is tedious, or there might not be a staging version (e.g. miscweb). To iterate, debug, or preview Nginx changes you can do the following on any wp-stage, codeorigin-stage, or miscweb host. |
16 | 31 |
|
17 |
| -The staging server is **wp-01.stage** (for all sites, including codeorigin). |
18 |
| - |
19 |
| -1. Edit the appropriate file under `/tmp/nginx.d/`, e.g. using `sudo nano` (vim isn't installable currently). |
20 |
| -2. Then perform the same notify command as Puppet would do: |
21 |
| - ``` |
22 |
| - sudo sh -c '/bin/cat /tmp/nginx.d/* > /etc/nginx/conf.d/vhost_autogen.conf' |
23 |
| - ``` |
24 |
| -3. Then reload the nginx service: |
| 32 | +1. Edit the appropriate file under `/etc/nginx/sites-available/`, e.g. using `sudo nano myfile.txt`. |
| 33 | +2. Perform reload nginx, just as Puppet would do: |
25 | 34 | ```
|
26 | 35 | sudo service nginx reload
|
27 | 36 | ```
|
28 |
| -4. Perform your test against HTTP localhost using `curl` and a Host header. Remember that on the staging server, the hostnames have a `stage.` prefix, for example: |
29 |
| - ``` |
30 |
| - wp-01.stage$ curl -i 'http://localhost/color/jquery.color-2.2.0.min.js' -H 'Host: stage.codeorigin.jquery.com' |
31 |
| -
|
32 |
| - wp-01.stage$ curl -i 'http://localhost/git/example-git.js' -H 'Host: stage.releases.jquery.com' |
33 |
| -
|
34 |
| - wp-01.stage$ curl -i 'http://localhost/purge/?uri=/qunit/' -H 'Host: stage.releases.jquery.com' |
35 |
| - wp-01.stage$ curl -i 'http://localhost/purge/?site=code&uri=/jquery-3.6.0.js' -H 'Host: stage.releases.jquery.com' |
36 |
| - wp-01.stage$ curl -i 'http://localhost/purge/?site=code&uri=/color/jquery.color-2.2.0.min.js' -H 'Host: stage.releases.jquery.com' |
37 |
| -
|
38 |
| - wp-03$ curl -i 'http://localhost/git/color/jquery.color-git.min.js' -H 'Host: releases.jquery.com' |
39 |
| - wp-03$ curl -i 'http://localhost/git/color/jquery.color-git.min.js' -H 'Host: codeorigin.jquery.com' |
40 |
| - wp-03$ curl -i 'http://localhost/color/color/jquery.color-2.2.0.min.js' -H 'Host: codeorigin.jquery.com' |
41 |
| -
|
| 37 | +3. Perform your test against HTTP localhost using `curl` and a Host header. Remember that on the staging server, the hostnames have a `stage.` prefix in the URL hostname: |
42 | 38 | ```
|
43 |
| - Or, to test from the outside, use `--connect-to` to bypass Cloudflare and simulate a direct request: |
44 |
| - ``` |
45 |
| - curl -I 'https://view.jquery.com/bar' --connect-to '::wp-01.ops.jquery.net' |
| 39 | + curl -I 'https://view.jquery.com/bar' --connect-to '::wp-05.ops.jquery.net' |
46 | 40 | ```
|
47 | 41 |
|
48 |
| -Beware that Puppet will run every 30 minutes and may overwrite these changes. |
49 |
| -* Check `sudo tail -n100 /var/log/syslog`, to see when Puppet last ran. |
50 |
| -* To temporarily disable puppet: `puppet agent --disable "message here"` |
| 42 | +Beware that Puppet will run every 30 minutes and may overwrite your changes while you're live hacking. |
| 43 | +* Check `sudo journalctl -u puppet -n 20`, to see when Puppet last ran. |
| 44 | +* To temporarily pause puppet: `puppet agent --disable "message here"` |
51 | 45 | * When done, re-enable puppet: `puppet agent --enable`
|
52 |
| -* To undo your changes, run puppet so that it restores the state: `puppet agent -tv`. |
53 |
| - |
54 |
| -## See also |
| 46 | +* To undo your changes, simply run puppet: `sudo run-puppet-agent`. |
55 | 47 |
|
56 |
| -Ref https://github.com/jquery/infrastructure/commit/79ae864005a12dab9affa502fd5dc5291fff504c |
0 commit comments