Nginx – How to rewrite HTML at the HTTP server level

httphttpsnginxPROXY

I'm building a personal website using Nginx and I'd like to have the option of serving the same content over both HTTP and HTTPS. However, the content management system I'm using stores a lot of the URIs as HTTP. This results in a lot of mixed content when using HTTPS, and eventually results in entire pages being served over HTTP.

I'm considering using persistent Perl script to act as a proxy and rewrite HTML as it is served. The alternative seems to be finding or writing plugins for each Web software package I install.

Is there a better way to go about this?

Best Answer

If you can't configure your CMS to only generate relative links, try the HTTPSubModule. This module can search and replace text in the nginx response.