0

I am serving a webapp through reverse proxy (external https://myserver.com/test is proxied to that server's :8052/), and I would like to rewrite HTML links to make it functional; but they are left as-is. (Apache 2.4.56 at Debian 11.)

This is the config:

<Location /test>
    ProxyPass http://localhost:8052 retry=0
    ProxyPassReverse /
    SetOutputFilter proxy-html
    # disable compression so that there is no need for DEFLATE;proxy-html;INFLATE
    RequestHeader unset Accept-Encoding
    ProxyHTMLEnable On
    ProxyHTMLURLMap ^/ /test/
    LogLevel trace8
</Location>
RewriteRule ^/test$ /test/ [R]

I enabled the highest logging possible to see what is happening (below is a full log relevant to that request). As I read it

  1. Content-type is being matched first, finally landing at matched 'text/html'.

    Good.

  2. Then there should be the HTML proxy itself doing the work (rewriting URLs in the HTML).

    But this never happens, no trace of it in the log??

  3. Body being sent (Response sent with status 200, headers: ...)

    The content contains invalid links (such as <script src="/js/vendor.js">, should be <script src="/test/js/vendor.js"> instead).

Why is the HTML processing skipped?

  • I tried manually setting ProxyHTMLLinks script src (in case the global module configuration in /etc/apache2/mods-enabled/proxy_html.conf` were failing). Nothing changed.
  • I tried various other settings (removing SetOutputFilter, removing ProxyHTMLEnable), not had an effect on the output.

Any help appreciated.

[Tue Oct 03 11:59:12.939502 2023] [proxy:trace2] [pid 4107518] mod_proxy.c(884): [client 78.108.102.144:59006] AH03461: attempting to match URI path '/test/' against prefix '/test' for proxying 
[Tue Oct 03 11:59:12.939552 2023] [proxy:trace1] [pid 4107518] mod_proxy.c(1001): [client 78.108.102.144:59006] AH03464: URI path '/test/' matches proxy handler 'proxy:http://localhost:8052/' 
[Tue Oct 03 11:59:12.939581 2023] [authz_core:debug] [pid 4107518] mod_authz_core.c(843): [client 78.108.102.144:59006] AH01628: authorization result: granted (no directives) 
[Tue Oct 03 11:59:12.939587 2023] [core:trace3] [pid 4107518] request.c(360): [client 78.108.102.144:59006] request authorized without authentication by access_checker_ex hook: /test/ 
[Tue Oct 03 11:59:12.939614 2023] [proxy_http:trace1] [pid 4107518] mod_proxy_http.c(97): [client 78.108.102.144:59006] HTTP: canonicalising URL http://localhost:8052/ 
[Tue Oct 03 11:59:12.939681 2023] [proxy:trace2] [pid 4107518] proxy_util.c(2340): [client 78.108.102.144:59006] http: found worker http://localhost:8052 for http://localhost:8052/ 
[Tue Oct 03 11:59:12.939687 2023] [proxy:debug] [pid 4107518] mod_proxy.c(1506): [client 78.108.102.144:59006] AH01143: Running scheme http handler (attempt 0) 
[Tue Oct 03 11:59:12.939693 2023] [proxy_fcgi:debug] [pid 4107518] mod_proxy_fcgi.c(1054): [client 78.108.102.144:59006] AH01076: url: http://localhost:8052/ proxyname: (null) proxyport: 0 
[Tue Oct 03 11:59:12.939698 2023] [proxy_fcgi:debug] [pid 4107518] mod_proxy_fcgi.c(1059): [client 78.108.102.144:59006] AH01077: declining URL http://localhost:8052/ 
[Tue Oct 03 11:59:12.939703 2023] [proxy_http:trace1] [pid 4107518] mod_proxy_http.c(1897): [client 78.108.102.144:59006] HTTP: serving URL http://localhost:8052/ 
[Tue Oct 03 11:59:12.939725 2023] [proxy:debug] [pid 4107518] proxy_util.c(2596): [client 78.108.102.144:59006] AH00944: connecting http://localhost:8052/ to localhost:8052 
[Tue Oct 03 11:59:12.939874 2023] [proxy:debug] [pid 4107518] proxy_util.c(2819): [client 78.108.102.144:59006] AH00947: connected / to localhost:8052 
[Tue Oct 03 11:59:12.963567 2023] [proxy_http:trace3] [pid 4107518] mod_proxy_http.c(1226): [client 78.108.102.144:59006] Status from backend: 200 
[Tue Oct 03 11:59:12.963587 2023] [proxy_http:trace4] [pid 4107518] mod_proxy_http.c(825): [client 78.108.102.144:59006] Headers received from backend: 
[Tue Oct 03 11:59:12.963595 2023] [proxy_http:trace4] [pid 4107518] mod_proxy_http.c(855): [client 78.108.102.144:59006] X-Powered-By: Express 
[Tue Oct 03 11:59:12.963612 2023] [proxy_http:trace4] [pid 4107518] mod_proxy_http.c(855): [client 78.108.102.144:59006] Content-Type: text/html; charset=utf-8 
[Tue Oct 03 11:59:12.963619 2023] [proxy_http:trace4] [pid 4107518] mod_proxy_http.c(855): [client 78.108.102.144:59006] Content-Length: 5924 
[Tue Oct 03 11:59:12.963624 2023] [proxy_http:trace4] [pid 4107518] mod_proxy_http.c(855): [client 78.108.102.144:59006] ETag: W/"1724-Re4sPSuFqTDDg0neco8GN6drf8g" 
[Tue Oct 03 11:59:12.963629 2023] [proxy_http:trace4] [pid 4107518] mod_proxy_http.c(855): [client 78.108.102.144:59006] Vary: Accept-Encoding 
[Tue Oct 03 11:59:12.963634 2023] [proxy_http:trace4] [pid 4107518] mod_proxy_http.c(855): [client 78.108.102.144:59006] Date: Tue, 03 Oct 2023 09:59:12 GMT 
[Tue Oct 03 11:59:12.963647 2023] [proxy_http:trace4] [pid 4107518] mod_proxy_http.c(855): [client 78.108.102.144:59006] Connection: keep-alive 
[Tue Oct 03 11:59:12.963652 2023] [proxy_http:trace4] [pid 4107518] mod_proxy_http.c(855): [client 78.108.102.144:59006] Keep-Alive: timeout=5 
[Tue Oct 03 11:59:12.963666 2023] [proxy_http:trace3] [pid 4107518] mod_proxy_http.c(1655): [client 78.108.102.144:59006] start body send 
[Tue Oct 03 11:59:12.964046 2023] [xml2enc:debug] [pid 4107518] mod_xml2enc.c(195): [client 78.108.102.144:59006] AH01430: Content-Type is text/html;charset=utf-8 
[Tue Oct 03 11:59:12.964069 2023] [xml2enc:info] [pid 4107518] [client 78.108.102.144:59006] AH01431: Got charset utf-8 from HTTP headers 
[Tue Oct 03 11:59:12.964359 2023] [filter:trace4] [pid 4107518] mod_filter.c(168): [client 78.108.102.144:59006] Content-Type 'text/html;charset=utf-8' ... 
[Tue Oct 03 11:59:12.964370 2023] [filter:trace4] [pid 4107518] mod_filter.c(180): [client 78.108.102.144:59006] ... did not match 'application/xml' 
[Tue Oct 03 11:59:12.964374 2023] [filter:trace2] [pid 4107518] mod_filter.c(185): [client 78.108.102.144:59006] Content-Type condition for 'deflate' did not match 
[Tue Oct 03 11:59:12.964378 2023] [filter:trace4] [pid 4107518] mod_filter.c(168): [client 78.108.102.144:59006] Content-Type 'text/html;charset=utf-8' ... 
[Tue Oct 03 11:59:12.964382 2023] [filter:trace4] [pid 4107518] mod_filter.c(180): [client 78.108.102.144:59006] ... did not match 'application/wasm' 
[Tue Oct 03 11:59:12.964385 2023] [filter:trace2] [pid 4107518] mod_filter.c(185): [client 78.108.102.144:59006] Content-Type condition for 'deflate' did not match 
[Tue Oct 03 11:59:12.964388 2023] [filter:trace4] [pid 4107518] mod_filter.c(168): [client 78.108.102.144:59006] Content-Type 'text/html;charset=utf-8' ... 
[Tue Oct 03 11:59:12.964392 2023] [filter:trace4] [pid 4107518] mod_filter.c(180): [client 78.108.102.144:59006] ... did not match 'application/rss+xml' 
[Tue Oct 03 11:59:12.964395 2023] [filter:trace2] [pid 4107518] mod_filter.c(185): [client 78.108.102.144:59006] Content-Type condition for 'deflate' did not match 
[Tue Oct 03 11:59:12.964398 2023] [filter:trace4] [pid 4107518] mod_filter.c(168): [client 78.108.102.144:59006] Content-Type 'text/html;charset=utf-8' ... 
[Tue Oct 03 11:59:12.964402 2023] [filter:trace4] [pid 4107518] mod_filter.c(180): [client 78.108.102.144:59006] ... did not match 'application/x-javascript' 
[Tue Oct 03 11:59:12.964405 2023] [filter:trace4] [pid 4107518] mod_filter.c(180): [client 78.108.102.144:59006] ... did not match 'application/javascript' 
[Tue Oct 03 11:59:12.964408 2023] [filter:trace4] [pid 4107518] mod_filter.c(180): [client 78.108.102.144:59006] ... did not match 'application/ecmascript' 
[Tue Oct 03 11:59:12.964412 2023] [filter:trace2] [pid 4107518] mod_filter.c(185): [client 78.108.102.144:59006] Content-Type condition for 'deflate' did not match 
[Tue Oct 03 11:59:12.964415 2023] [filter:trace4] [pid 4107518] mod_filter.c(168): [client 78.108.102.144:59006] Content-Type 'text/html;charset=utf-8' ... 
[Tue Oct 03 11:59:12.964418 2023] [filter:trace4] [pid 4107518] mod_filter.c(174): [client 78.108.102.144:59006] ... matched 'text/html' 
[Tue Oct 03 11:59:12.964422 2023] [filter:trace2] [pid 4107518] mod_filter.c(185): [client 78.108.102.144:59006] Content-Type condition for 'deflate' matched 
[Tue Oct 03 11:59:12.964455 2023] [http:trace3] [pid 4107518] http_filters.c(1129): [client 78.108.102.144:59006] Response sent with status 200, headers: 
[Tue Oct 03 11:59:12.964461 2023] [http:trace5] [pid 4107518] http_filters.c(1138): [client 78.108.102.144:59006]   Date: Tue, 03 Oct 2023 09:59:12 GMT 
[Tue Oct 03 11:59:12.964465 2023] [http:trace5] [pid 4107518] http_filters.c(1141): [client 78.108.102.144:59006]   Server: Apache/2.4.56 (Debian) 
[Tue Oct 03 11:59:12.964469 2023] [http:trace4] [pid 4107518] http_filters.c(959): [client 78.108.102.144:59006]   X-Powered-By: Express 
[Tue Oct 03 11:59:12.964473 2023] [http:trace4] [pid 4107518] http_filters.c(959): [client 78.108.102.144:59006]   Content-Type: text/html;charset=utf-8 
[Tue Oct 03 11:59:12.964476 2023] [http:trace4] [pid 4107518] http_filters.c(959): [client 78.108.102.144:59006]   ETag: W/\\"1724-Re4sPSuFqTDDg0neco8GN6drf8g\\" 
[Tue Oct 03 11:59:12.964502 2023] [http:trace4] [pid 4107518] http_filters.c(959): [client 78.108.102.144:59006]   Vary: Accept-Encoding 
[Tue Oct 03 11:59:12.964506 2023] [http:trace4] [pid 4107518] http_filters.c(959): [client 78.108.102.144:59006]   Content-Length: 5844 
[Tue Oct 03 11:59:12.964509 2023] [http:trace4] [pid 4107518] http_filters.c(959): [client 78.108.102.144:59006]   Keep-Alive: timeout=5, max=100 
[Tue Oct 03 11:59:12.964520 2023] [http:trace4] [pid 4107518] http_filters.c(959): [client 78.108.102.144:59006]   Connection: Keep-Alive 
[Tue Oct 03 11:59:12.964614 2023] [proxy_http:trace2] [pid 4107518] mod_proxy_http.c(1796): [client 78.108.102.144:59006] end body send 
1
  • make sure wherever you specify ProxyHTMLLinks is being read (add gargabe to see if httpd still starts) Oct 5 at 16:05

0

You must log in to answer this question.

Browse other questions tagged .