|
| 1 | +# Runbook: Nginx debugging |
| 2 | + |
| 3 | +## Staging and testing |
| 4 | + |
| 5 | +* Push to `puppet-stage`. |
| 6 | +* Apply on **wp-01.stage**.ops by running `sudo puppet agent -tv` there. |
| 7 | + * If there are errors, especially the `Nginx[refresh]` line, then stop and fix the patch. |
| 8 | + * 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. |
| 12 | + |
| 13 | +## Live hacking |
| 14 | + |
| 15 | +To test and **debug Nginx changes** for jQuery content sites hosted on wp-01, wp-02, or wp03. |
| 16 | + |
| 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: |
| 25 | + ``` |
| 26 | + sudo service nginx reload |
| 27 | + ``` |
| 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 | +
|
| 42 | + ``` |
| 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' |
| 46 | + ``` |
| 47 | + |
| 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"` |
| 51 | +* 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 |
| 55 | + |
| 56 | +Ref https://github.com/jquery/infrastructure/commit/79ae864005a12dab9affa502fd5dc5291fff504c |
0 commit comments