I have a simple Flask application hosting a form for a data input into local db. I am validating one of the field with wdsl service with python zeep (simply checks if VAT exists with http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl) The application server is behind corporate proxy. Both http_proxy and https_proxy are set. wdsl service returns data as intended while testing (localhost, or running validation function directly with python) When I run the app with Apache2, suddenly the network is unreachable. I believe I have missing some configuration in Flaskapp.conf which would route the traffic through the corporate proxy. Could anybody help/direct me here? Thank you.
urlib3 error:
File "/home/administrator/v_env/flaskapp/lib/python3.6/site-packages/urllib3/connection.py", line 170, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw
File "/home/administrator/v_env/flaskapp/lib/python3.6/site-packages/urllib3/util/connection.py", line 96, in create_connection
raise err
File "/home/administrator/v_env/flaskapp/lib/python3.6/site-packages/urllib3/util/connection.py", line 86, in create_connection
sock.connect(sa)
OSError: [Errno 101] Network is unreachable
Flaskapp.conf
<VirtualHost *:80>
ServerName $stationIP
ServerAdmin name@domain.com
WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi
<Directory /var/www/FlaskApp/FlaskApp/>
Order allow,deny
Allow from all
</Directory>
Alias /static /var/www/FlaskApp/FlaskApp/static
<Directory /var/www/FlaskApp/FlaskApp/static/>
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
validation function
def validate_vat(self, vat):
transport = Transport(timeout=10)
try:
client = Client('http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl', transport=transport)
client.transport.session.proxies = {'http':'http://<proxy.server.com>:9090'}
response = client.service.checkVat(vat.data[0:2].upper(), vat.data[2:])
except:
raise wtforms.validators.ValidationError('VAT validation service unavailable. Please try again later')
if not response.valid:
raise wtforms.validators.ValidationError('Not a valid VAT')