- Issue created by @namwebs
- Status changed to Postponed: needs info
12 months ago 1:20pm 20 November 2023 - 🇳🇴Norway andeersg
Hi,
This module does not manipulate the input urls. Are you sure you are not getting mixed content errors in your browser?
Most browsers will prevent loading content from HTTP resources when on a HTTPS site.
- 🇳🇦Namibia namwebs
Hi,
Thanks for the response. Yes, this is definitely the problem. The message is
temp:1 Mixed Content: The page at 'https://mywebsite/temp' was loaded over HTTPS, but requested an insecure element 'http://mygeoserverurl:8080/geoserver/speciesmaps/wms?service=WMS&request=GetMap&layers=...etc'. This request was automatically upgraded to HTTPS.
So then it is a browser issue and not a module issue. I'm not sure how to get round this. I can't upgrade the geoserver to https. Is there a way to directly load a shapefile in leaflet layers?
Thanks.
- 🇳🇴Norway andeersg
I'm not sure. You will get better answers about Leaflet in some of the places mentioned at the bottom of https://leafletjs.com/.
But I guess the simplest would be to create a proxy webservice that is served with HTTPS and fetches data from mygeoserverurl:8080.
- 🇳🇦Namibia namwebs
Thanks andeersg for your response. I'm looking into that.
This issue can be marked closed, I suppose, since it's not really a problem with the module itself.
- Status changed to Closed: works as designed
12 months ago 12:13pm 22 November 2023 - 🇳🇦Namibia namwebs
In case it helps someone, this is what we did to get around the mixed content problem (of having the site on https and the geoserver on http):
1. In Map Layers, point the URL template to a local php file e.g.https://mysite-url/tile.php
2. In the php file, have this code:<?php $sourceURL = 'http://mygeoserverrul:8080/geoserver/foldername/wms'; $newURL = $sourceURL.'?'. http_build_query($_REQUEST); if (!file_exists("./tiles")) { mkdir("./tiles"); } $fileLocation = "./tiles/".md5($newURL).".png"; if (!file_exists($fileLocation)) { $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $newURL); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HEADER, false); $imageData = curl_exec($curl); curl_close($curl); file_put_contents($fileLocation, $imageData); } header("Content-type: ".mime_content_type($fileLocation)); echo file_get_contents($fileLocation); die();
As long as you don't have commas or special characters in the geoserver filename, this works perfectly (for my use case, at least!).