3

I'm having trouble displaying some base maps on parts or my organisations network. I set up a QGIS (2.14.9) project and added a couple of layers. I then add a google basemap using 'Thomas B' instructions from here:

High resolution, printable alternative to OpenLayers plugin for QGIS?

All good.

I took my laptop to work where I have to use a proxy server. OpenLayers and QuickMapServices failed to load until I set the Proxy Server parameters. However, the xml files just render as a black background because I think they do not use the proxy settings. They work fine if I'm on the orgnaisation's wireless network.

Assuming I'm correct, is there a way to get the xml files to use the proxy settings?

  • You could try using that XML file in gdal to get better diagnostics / see what is really happening. Perhaps your organisation's site is being blocked by google, or by some firewall on your side. There are a lot of options. – BradHards Dec 20 '16 at 7:11
  • I don't think Google is being blocked as this url returns a tile: mt.google.com/vt/… – Colin Dec 20 '16 at 21:44
  • Excuse my ignorance but how would I run the xml through GDAL? – Colin Dec 20 '16 at 21:45
  • gdal.org/frmt_wms.html shows some examples. The XML format is a GDAL format (hence the <GDAL_WMS> part at the start). – BradHards Dec 20 '16 at 22:53
  • @BradHards: I'm using a Win10 Laptop and ran gdalinfo (>gdalinfo "WMS:mt.google.com/vt/…). This returns a 403 error. The URL in the command returns a tile in IE11. However, if I uncheck the 'use proxy server' in IE>Internet options>connections>LAN Setting then I also get a 403 error. So I think this somewhat confirms that the issue is that GDAL is not using the proxy settings in QGIS. Is there a way of getting GDAL to use the proxy settings in QGIS Settings>Options>Network? – Colin Dec 21 '16 at 0:26
3

The easiest way to check this is to isolate the QGIS part from the underlying GDAL part (which is what your XML uses). You can test using a command line, as explained in http://gdal.org/frmt_wms.html, which also explains the general syntax for the XML file.

Based on comments, it does appear that proxy settings are the problem.

GDAL uses the curl library for the HTTP/HTTPS layer, and that respects http_proxy environment variable. However you can also specify a GDAL_HTTP_PROXY environment variable, along with GDAL_HTTP_PROXYUSERPWD and GDAL_PROXY_AUTH if you need to authenticate to the proxy.

From https://trac.osgeo.org/gdal/wiki/ConfigOptions:

GDAL_HTTP_PROXY

Set HTTP proxy to use. The parameter should be the host name or dotted IP address. To specify port number in this string, append :[port] to the end of the host name. The proxy string may be prefixed with [protocol]: since any such prefix will be ignored. The proxy's port number may optionally be specified with the separate option. If not specified, libcurl will default to using port 1080 for proxies.

GDAL respects the environment variables http_proxy, ftp_proxy, all_proxy etc, if any of those are set. GDAL_HTTP_PROXY option does however override any possibly set environment variables.

GDAL_HTTP_PROXYUSERPWD

The HTTP user and password to use for the connection to the HTTP proxy. Must be in the form of [user name]:[password].

GDAL_PROXY_AUTH

Set value to [BASIC/NTLM/DIGEST/ANY] to tell libcurl which authentication method(s) you want it to use for your proxy authentication. See ​http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTPROXYAUTH for more information

On Windows 10, you can set these variables under Control Panel -> System and Security -> System. Use Advanced System settings and look at the bottom of the "Advanced" tab for "Environment Variables...". Or a web search will probably give you step-by-step instructions - one solution is at https://superuser.com/questions/284342/what-are-path-and-other-environment-variables-and-how-can-i-set-or-use-them

  • Thanks @BradHards. Adding these three environment variables worked. :-) I added them as systems variables as user variables didn't seem to work. I did restart QGIS so I'm not sure if that was the difference. – Colin Dec 21 '16 at 2:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.