I have a docker API server running locally on port 9000, and a node client fetching this API using POST. When HTTP-Toolkit is set to intercept, it successfully creates another container and restart the API container with added proxy environment variables:
HTTP_PROXY=http://172.17.0.1:8000
HTTPS_PROXY=http://172.17.0.1:8000
http_proxy=http://172.17.0.1:8000
https_proxy=http://172.17.0.1:8000
WS_PROXY=http://172.17.0.1:8000
WSS_PROXY=http://172.17.0.1:8000
GLOBAL_AGENT_HTTP_PROXY=http://172.17.0.1:8000
CGI_HTTP_PROXY=http://172.17.0.1:8000
npm_config_proxy=http://172.17.0.1:8000
npm_config_https_proxy=http://172.17.0.1:8000
npm_config_scripts_prepend_node_path=false
SSL_CERT_FILE=/.http-toolkit-injections/ca.pem
NODE_EXTRA_CA_CERTS=/.http-toolkit-injections/ca.pem
DENO_CERT=/.http-toolkit-injections/ca.pem
PERL_LWP_SSL_CA_FILE=/.http-toolkit-injections/ca.pem
GIT_SSL_CAINFO=/.http-toolkit-injections/ca.pem
CARGO_HTTP_CAINFO=/.http-toolkit-injections/ca.pem
CURL_CA_BUNDLE=/.http-toolkit-injections/ca.pem
AWS_CA_BUNDLE=/.http-toolkit-injections/ca.pem
HTTP_TOOLKIT_ACTIVE=true
HTTP_TOOLKIT_OVERRIDE_PATH=/.http-toolkit-injections/overrides
PATH=/.http-toolkit-injections/overrides/path:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
RUBYLIB=/.http-toolkit-injections/overrides/gems
PYTHONPATH=/.http-toolkit-injections/overrides/pythonpath
NODE_OPTIONS=--require /.http-toolkit-injections/overrides/js/prepend-node.js
JAVA_TOOL_OPTIONS=-javaagent:"/.http-toolkit-injections/overrides/java-agent.jar"=172.17.0.1|8000|/.http-toolkit-injections/ca.pem
PHP_INI_SCAN_DIR=/.http-toolkit-injections/overrides/php
DOCKER_BUILDKIT=0
But,
AFAIU, I shouldn't need to change to 8000, but I don't get what I'm missing to intercept. Is there a more manual way to set it up as a passthrough?
Finally, when I shut down HTTP-Toolkit, it DELETES the API container! Is there a way to prevent this behavior?
HTTP Toolkit (and all similar tools) act as HTTP proxies. That means that to intercept traffic using them, you need to configure the client to use the proxy settings, not the server.
Based on your description, that means you shouldn't be using HTTP Toolkit's Docker interception at all. That is designed to intercept traffic sent from your Docker container to a server elsewhere (e.g. a 3rd party API, or another Docker container).
If you want to intercept traffic to your Docker container, you need to intercept the client who is doing to sending. It sounds like that's a node process on your machine? To intercept a node process, you just open an intercepted terminal from HTTP Toolkit and run the node process there as normal. All traffic sent from processes inside that terminal will be intercepted.