Map layer entities being forced to https

Created on 20 November 2023, 7 months ago
Updated 27 November 2023, 7 months ago

Thanks for this module. I can almost get it to do what I want.

Problem/Motivation

I want to add a map layer from my geoserver which is hosted separately from my website. My geoserver is on an http (not https) address. If my website is served as http, the geoserver layer is displayed correctly. If my website is served as https (which is how I want it), the geoserver layer does not display and the error is: ERR_SSL_PROTOCOL_ERROR.

In the map layer entities settings I am putting the URL template as http://www.mygeoserverurl.com:8080/geoserver/speciesmaps/wms but this is apparently being converted somewhere into https://www.mygeoserverurl.com:8080/geoserver/speciesmaps/wms. How can I force it to use the URL template I have entered (http) and not https?

(It's not an option to host the geoserver on https for various reasons.)

Any help will be gratefully received! Thanks.

Steps to reproduce

Enter an http address in URL template. Inspect the code on the page and see that the address has been converted to https.

πŸ’¬ Support request
Status

Closed: works as designed

Version

1.1

Component

Code

Created by

πŸ‡³πŸ‡¦Namibia namwebs

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @namwebs
  • πŸ‡³πŸ‡¦Namibia namwebs
  • Status changed to Postponed: needs info 7 months ago
  • πŸ‡³πŸ‡΄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 7 months ago
  • πŸ‡³πŸ‡΄Norway andeersg

    Thank you, hope you find a solution for your problem :)

  • πŸ‡³πŸ‡¦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!).

Production build 0.69.0 2024