I have nginx sitting in front of a web application running on localhost listening on port 8085 whose HTML source files I cannot modify. These source files load Google fonts via http rather than https and this generates mixed content warnings in my users browsers.
As a result I'd like to rewrite the http calls to the Google fonts on the fly as the pages are proxied through nginx on their way to my users. In other words I want to rewrite:
http://fonts.googleapis.com/css?family=Roboto:400,700&subset=latin,cyrillic,greek,vietnamese
to:
https://fonts.googleapis.com/css?family=Roboto:400,700&subset=latin,cyrillic,greek,vietnamese
in the page /application/example.html
I have the following block in my reverse-proxy.conf file which I thought would do it:
location /application/ { proxy_pass http://127.0.0.1:8085; # Replace http calls to Google with https ones proxy_set_header Accept-Encoding ""; sub_filter 'http://fonts.googleapis' 'https://fonts.googleapis'; sub_filter_once off; access_log off; } but it doesn't appear to work. I've seen mentions that I need to enable sub_filter when compiling nginx but I didn't compile it - it was installed via apt-get on Debian. Is there a way to determine if sub_filter is enabled ?
Just to be clear, I'm not trying to rewrite my site URL's to use https instead of http, I'm trying to rewrite non-https off-site URL's. This seems to be a trivial problem but I've Googled extensively but can't find any working examples so any advice would be much appreciated.