Minor profiling page adjustments

This commit is contained in:
Francis Lavoie 2023-11-06 04:27:36 -05:00
parent aab887d97c
commit cce02cd922
No known key found for this signature in database
GPG key ID: 0F66EE1687682239
2 changed files with 26 additions and 8 deletions

View file

@ -132,7 +132,7 @@ Save that to a file named `Caddyfile` (no extension) in the current directory.
<aside class="complete">Make a Caddyfile</aside>
Stop Caddy if it is already running (Ctrl+C), then run:
Stop Caddy if it is already running (<kbd>Ctrl</kbd>+<kbd>C</kbd>), then run:
<pre><code class="cmd bash">caddy adapt</code></pre>
@ -233,7 +233,7 @@ As you can see, Caddy is well-suited for a wide variety of use cases and deploym
## Start, stop, run
Since Caddy is a server, it runs indefinitely. That means your terminal won't unblock after you execute `caddy run` until the process is terminated (usually with Ctrl+C).
Since Caddy is a server, it runs indefinitely. That means your terminal won't unblock after you execute `caddy run` until the process is terminated (usually with <kbd>Ctrl</kbd>+<kbd>C</kbd>).
Although `caddy run` is the most common and is usually recommended (especially when making a system service!), you can alternatively use `caddy start` to start Caddy and have it run in the background:
@ -241,7 +241,7 @@ Although `caddy run` is the most common and is usually recommended (especially w
This will let you use your terminal again, which is convenient in some interactive headless environments.
You will then have to stop the process yourself, since Ctrl+C won't stop it for you:
You will then have to stop the process yourself, since <kbd>Ctrl</kbd>+<kbd>C</kbd> won't stop it for you:
<pre><code class="cmd bash">caddy stop</code></pre>
@ -256,7 +256,7 @@ Your server can perform zero-downtime config reloads/changes.
All [API endpoints](/docs/api) that load or change config are graceful with zero downtime.
When using the command line, however, it may be tempting to use Ctrl+C to stop your server and then restart it again to pick up the new configuration. Don't do this: stopping and starting the server is orthogonal to config changes, and will result in downtime.
When using the command line, however, it may be tempting to use <kbd>Ctrl</kbd>+<kbd>C</kbd> to stop your server and then restart it again to pick up the new configuration. Don't do this: stopping and starting the server is orthogonal to config changes, and will result in downtime.
<aside class="tip">
Stopping your server will cause the server to go down.

View file

@ -91,7 +91,7 @@ Once your profiles are downloaded, you can upload them to a GitHub issue comment
_If you're already able to access the admin API locally, skip this section._
By default, Caddy's admin API is only accessible over the loopback socket. However, there are at least 3 ways you can access Caddy's /debug/pprof endpoint remotely:
By default, Caddy's admin API is only accessible over the loopback socket. However, there are at least 3 ways you can access Caddy's `/debug/pprof` endpoint remotely:
### Reverse proxy through your site
@ -107,22 +107,40 @@ This will, of course, make profiles available to who can connect to your site. I
(Don't forget the `/debug/pprof/*` matcher, otherwise you'll proxy the entire admin API!)
### SSH tunnel
Another way is to use an SSH tunnel. This is an encrypted connection using the SSH protocol between your computer and your server. Run a command like this on your computer:
<pre><code class="cmd bash">ssh -N username@example.com -L 8123:localhost:2019</code></pre>
This tunnels `localhost:8123` to `example.com:2019`. Make sure to replace `username`, `example.com`, and ports as necessary.
This tunnels `localhost:8123` (on your local machine) to `localhost:2019` on `example.com`. Make sure to replace `username`, `example.com`, and ports as necessary.
<aside class="tip">
This command will run in the foreground. Keep in mind that if you try to background the process with <kbd>Ctrl</kbd>+<kbd>Z</kbd>, it will pause the tunnel, and connections using the tunnel will fail to connect.
</aside>
Then in another terminal you can run `curl` like so:
<pre><code class="cmd bash">curl -v http://localhost:8123/debug/pprof/ -H "Host: localhost:2019"</code></pre>
You can avoid the need for `-H "Host: ..."` by using port 2019 on both sides of the tunnel (but this requires that port 2019 is not already taken on your own computer).
You can avoid the need for `-H "Host: ..."` by using port `2019` on both sides of the tunnel (but this requires that port `2019` is not already taken on your own computer, i.e. not having Caddy running locally).
While the tunnel is active, you can access any and all of the admin API. Type <kbd>Ctrl</kbd>+<kbd>C</kbd> on the `ssh` command to close the tunnel.
#### Long-running tunnel
Running a tunnel with the above command requires that you keep the terminal open. If you want to run the tunnel in the background, you can start the tunnel like this:
<pre><code class="cmd bash">ssh -f -N -M -S /tmp/caddy-tunnel.sock username@example.com -L 8123:localhost:2019</code></pre>
This will start in the background and create a control socket at `/tmp/caddy-tunnel.sock`. You can then use the control socket to close the tunnel when you're done with it:
<pre><code class="cmd bash">ssh -S /tmp/caddy-tunnel.sock -O exit e</code></pre>
### Remote admin API
You can also configure the admin API to accept remote connections to authorized clients.