I have HTTP to HTTPS redirect configured in server, to display json data coming from arduino MCU on port 8090 I need to restrict http to https redirect, so following this I have configured my apache web server to below
<VirtualHost *:80>
RewriteEngine on
ServerName 192.168.1.45
# force ssl
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
# force HTTP for /arduino
RewriteCond %{HTTPS} =on
RewriteRule ^(arduino) http://%{SERVER_NAME}%{REQUEST_URI} [L,R]
</VirtualHost>
then I restarted apache server and refreshed the page but I am still getting the error in browser console saying:
[Warning] [blocked] The page at https://www.example.com/arduino/gauge.htm was not allowed to display insecure content from http://www.example.com:8090/json. (jquery.min.js, line 5)
I have even tried :
<VirtualHost *:80>
RewriteEngine on
ServerName 192.168.1.45
# force ssl
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
# force HTTP for /json
RewriteCond %(SERVER_PORT} ^8090
RewriteCond %{HTTPS} =on
RewriteRule ^(json) http://%{SERVER_NAME}%{REQUEST_URI} [L,R]
</VirtualHost>
but it doesnt work. same error in console, any help will be greatly appreciated.
I suspect that the issue is in the browser (client) not in your server config. For security reasons most of modern browser blocks all http requests when you get a page from https domain, in your case: https://san.gotdns.ch/arduino/gauge.htm
In MDN:
Maybe this article could be useful for you:
https://developer.mozilla.org/en-US/docs/Web/Security/Mixed_content/How_to_fix_website_with_mixed_content
The interesting part: