Skip to content

How to Configure Apache mod_proxy_html for Content Rewriting

DodaTech Updated 2026-06-24 2 min read

mod_proxy_html rewrites HTML links in proxied content so they point to the correct proxy URLs. It is essential for reverse proxy setups where backend URLs differ from public URLs. This guide walks through the specific troubleshooting steps to diagnose and resolve HTML rewriting issues.

Before You Begin

Before you begin, be sure to have the following in place:

  • A Linux server with the relevant software installed
  • Access to the command line interface
  • Appropriate permissions (root or sudo)

Quick Fix

Wrong

ProxyPass / http://backend/ (HTML links point to backend URLs)

Wrong: Proxying HTML without rewriting links

ProxyHTMLEnable On\nProxyHTMLURLMap http://backend /

Right: HTML link rewriting with mod_proxy_html

Output

mod_proxy_html enabled\nURL mapping: http://backend/ → /\nHTML links rewritten for correct proxying

Prevention

To avoid future issues, follow these best practices:

  • Enable mod_proxy_html with a2enmod proxy_html
  • Use ProxyHTMLURLMap to map backend URLs to proxy URLs
  • Handle multiple URL mappings if the backend uses different URLs
  • Enable ProxyHTMLMeta to Process HTML meta refresh tags
  • Test with a browser to verify all links are correctly rewritten

DodaTech Tools

For further assistance with any of the above issues, consider using DodaTech consulting services or DodaTech tutorials for more in-depth guidance.

Common Mistakes with mod proxy html

  1. Forgetting that lazy evaluation defers computation until the value is forced, causing space leaks with unevaluated thunks
  2. Using return to exit a function early instead of wrapping a pure value in the monad
  3. Mixing let bindings with <- bindings in do notation, producing type errors

These mistakes appear frequently in real-world APACHE code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

Why do I need mod_proxy_html?|||When proxying content, HTML links, images, and CSS references point to the backend server. mod_proxy_html rewrites these to point to the proxy URLs.
Does mod_proxy_html handle JavaScript links? No. mod_proxy_html only handles HTML content. JavaScript-generated URLs must be handled separately or configured in the application.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro