Repository

Looks good to me!

User Tools

Site Tools


kb:tools:mitmproxy

Very useful for understanding what is going on in nginx proxy.

pip3 install mitmproxy

Config: ~/.mitmproxy/config.yaml

Quick documentation:

location /app/ {
    proxy_pass http://localhost:1234/app;
    ...
}

The initial response is ok, i.e. the page at /app is obtained. But the other requests are not going through, i.e. /app/static/.... The page to be served is /app/#/login, but somehow that redirects to /app. Thought it might be this issue: https://stackoverflow.com/questions/36688891/nginx-redirect-to-url-with-url

Inspection of response headers show in console: style not applied due to 'text/html' not a spreadsheet type, and strict MIME check is enabled., and under network: Status: 302 Found; Content-Type: text/html; for a .css file. Tried adding MIME types: https://stackoverflow.com/questions/29573489/nginx-failing-to-load-css-and-js-files-mime-type-error

But ultimately I still don't know what request is being proxied.

Tried mirroring requests: http://nginx.org/en/docs/http/ngx_http_mirror_module.html A good article on what mirroring actually does. https://alex.dzyoba.com/blog/nginx-mirror/

Used mitmproxy, quite easy to setup, esp since backend is http and not https.

Notice how the URI forwarded is /appstatic/ and not /app/static/

Some lessons learnt?

  • Need to debug and know what is going on step-by-step. Playing around and checking is the most effective way to learn.
  • If core basic knowledge is not there, debugging is a difficult process, because not clear what the problem is.
  • Caching is troublesome to work around...
kb/tools/mitmproxy.txt · Last modified: 19 months ago ( 2 May 2023) by 127.0.0.1