Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MetaSearch: Allow use of proxy #53159

Open
bstroebl opened this issue May 19, 2023 · 10 comments
Open

MetaSearch: Allow use of proxy #53159

bstroebl opened this issue May 19, 2023 · 10 comments

Comments

@bstroebl
Copy link

Feature description

The MeaSeach core plugin does not work if the client running QGIS is behind a proxy. Best solution would be to use the proxy set in QGIS' network settings. I assume this would need the implementation of #24214 . A workaround could be to configure a proxy in the plugin's settings.
As is the plugin is unusable for any institutional QGIS' users, normally being situated behind a proxy.

Additional context

No response

@agiudiceandrea
Copy link
Contributor

@bstroebl, as a workaround, does setting the environment varible HTTP_PROXY or HTTPS_PROXY work for your use case? See https://requests.readthedocs.io/en/latest/user/advanced/?highlight=proxies#proxies and https://docs.qgis.org/3.28/en/docs/user_manual/introduction/qgis_configuration.html#system-settings

@bstroebl
Copy link
Author

@agiudiceandrea Thank you for your reply. Do you mean if setting the environment variable works technically or if it is feasible? Anyways, currently there is no defined use case. I am just checking out, if MeaSearch could be of use in an administrative context for several administrations of which I have neither information on the technical settings nor the potential users' personal capabilities. I am convinced at least some of them are behind a proxy but I doubt setting environment variables on every user's client is feasible. On the other hand I would expect them to be able to configure QGIS' proxy settings otherwise no Services like WMS would be available from servers on the internet.

@agiudiceandrea
Copy link
Contributor

agiudiceandrea commented May 22, 2023

@bstroebl have you tested if setting such environment variable(s) in QGIS makes the MetaSearch plugin able to connect to Internet through a proxy? If not, could you please test it?
Considering that this would be a workaround, it seems to me that adding an environment variable in QGIS is no more difficult then changing a setting in QGIS.

@bstroebl
Copy link
Author

Will try to test as I have to check out the proxy server's address first. Stay tuned.

@bstroebl
Copy link
Author

bstroebl commented Jun 7, 2023

Sorry, no news on this topic

@pathmapper
Copy link
Contributor

does setting the environment varible HTTP_PROXY or HTTPS_PROXY work for your use case?

Setting these doesn't help in my case (simple http proxy without auth).

This should be labeled as a bug, there is already some logic to use QGIS proxy settings:

def install_proxy(self):
"""set proxy if one is set in QGIS network settings"""
# initially support HTTP for now
if self.settings.value('/proxy/proxyEnabled') == 'true':
if self.settings.value('/proxy/proxyType') == 'HttpProxy':
ptype = 'http'
else:
return
user = self.settings.value('/proxy/proxyUser')
password = self.settings.value('/proxy/proxyPassword')
host = self.settings.value('/proxy/proxyHost')
port = self.settings.value('/proxy/proxyPort')
proxy_up = ''
proxy_port = ''
if all([user != '', password != '']):
proxy_up = f'{user}:{password}@'
if port != '':
proxy_port = ':%s' % port
conn = f'{ptype}://{proxy_up}{host}{proxy_port}'
install_opener(build_opener(ProxyHandler({ptype: conn})))

I've verified that proxy settings are correctly read in the code above by MetaSearch but it's not possible to make a connection to any service behind a proxy.

grafik

@tomkralidis any idea / hint what could be the issue?

@agiudiceandrea
Copy link
Contributor

agiudiceandrea commented May 16, 2024

@pathmapper, have you set the HTTPS_PROXY environment variable? How have you set it?

@pathmapper
Copy link
Contributor

have you set the HTTPS_PROXY environment variable? How have you set it?

Yep, in Settings -> Options -> System -> Environment

grafik

The error message displayed by MetaSearch is then different:

grafik

@agiudiceandrea
Copy link
Contributor

@pathmapper, so this means that setting the *_PROXY environment variable actually changes the connection behavior. Anyway looking at the screenshots, it seems to me such variable are not properly set: they miss the "scheme" (http://) part. They should be something like http://proxy_user:proxy_password@proxy_host_ip:proxy_host_port.

@pathmapper
Copy link
Contributor

@agiudiceandrea thanks, adding http:// to the value works :-)

So we are having a workaround 👍

Not sure if this fixes the use case of @bstroebl.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants