Difference between revisions of "Localyzer Machine Translation through a Proxy Server"

From Lingoport Wiki
Jump to: navigation, search
Line 61: Line 61:
 
You can add a step to your Jenkins Automation build(s) to confirm that the proxy is used. To do so:
 
You can add a step to your Jenkins Automation build(s) to confirm that the proxy is used. To do so:
   
: Start at the Jenkins HomePage
+
# Start at the Jenkins HomePage
: Select the build you would like to test with. For example 'MyCompany.MyProject' -> (Goes to a new page)
+
# Select the build you would like to test with. For example 'MyCompany.MyProject' -> (Goes to a new page)
: Go to Configure on the left -> (Goes to a new page)
+
# Go to Configure on the left -> (Goes to a new page)
  +
# Scroll to the bottom of the Configure page. You should see an 'Add build step' button just '''above''' 'Post-build actions'
:
 
  +
# Add build step -> Execute shell -> (An empty 'Execute shell' box should appear)
  +
# In the box, add the following content:
  +
<pre>
  +
set +e # curl may fail without the proxy, depending on network configuration.
  +
set +x # optional setting. Don't show commands run, so output is clearer.
  +
echo
  +
echo "Validating Proxy is Used:"
  +
echo
  +
echo "Attempting connection without proxy. May timeout if network blocks traffic without proxy."
  +
echo "Otherwise, should return the external ip of the system."
  +
echo -n "IP returned: "
  +
https_proxy="" curl https://canhazip.com --silent --connect-timeout 5 || echo "NOTE: Without proxy, connection timed out after 5 seconds."
  +
echo
  +
echo "Attempting connection with proxy. Proxy is valid if connection succeeds."
  +
echo "Should return the external ip of the proxy server."
  +
echo " details: https_proxy set to: $https_proxy"
  +
echo -n "IP returned: "
  +
curl "https://canhazip.com" --silent --connect-timeout 5 || echo "FAILED: With the proxy set, connection timed out after 5 seconds."
  +
echo
  +
echo
  +
</pre>
  +
# After you have filled it out, drag and drop this box so that it is moved higher, above any other boxes such as 'Update Dashboard' or 'L10n Vendor'. This way it runs first.
  +
# Save the build. Then run it. Navigate to the console output of the build. You should see a section that shows:
  +
<pre>
  +
Validating Proxy is Used:
  +
  +
Attempting connection without proxy. May timeout if network blocks traffic without proxy.
  +
Otherwise, should return the external ip of the system.
  +
IP returned: 34.195.141.162
  +
  +
Attempting connection with proxy. Proxy is valid if connection succeeds.
  +
Should return the external ip of the proxy server.
  +
details: https_proxy set to: http://masnes.testproxy.internal.lingoport.io:3128
  +
IP returned: 54.205.127.98
  +
</pre>

Revision as of 19:43, 4 November 2020

Rational

A proxy Server may be used for Localyzer AWS Machine Translation if necessary for IT/Network/Security requirements.

This is done by setting the 'https_proxy' environment variable. Another variable, 'http_proxy', is available for http connections, but will not be needed for use with Amazon Translate.

Proxy Validation

It is recommended that you validate you have access to your proxy from your system, prior to enabling it.

Test steps (example proxy used is http://masnes.testproxy.internal.lingoport.io:3128):

  • ssh to your system
  • install 'telnet', if it is not already present
sudo yum install telnet
  • validate that you can connect to your proxy server, while keeping proxy settings clear - for now:
http_proxy="" https_proxy="" telnet <proxyurl-no-http/s> <proxyport>
Example:
http_proxy="" https_proxy="" telnet masnes.testproxy.internal.lingoport.io 3128
Result
Trying 172.31.81.146...
Connected to masnes.testproxy.internal.lingoport.io.
Escape character is '^]'.
Note: Enter will quit and return you to your terminal.
If the connection takes more than 5 seconds, you may not be able to connect to the proxy, please check your networking connection settings before continuing.
  • Next, as a comparison point, try curling + to an external site that will return the found ip address, without using the proxy settings yet.
Here, we use 'https://canhazip.com' as the external site. We set a timeout in case the connection is blocked.
Command
https_proxy="" curl https://canhazip.com --silent --connect-timeout 5 || echo "NOTE: ...Connection timed out after 5 seconds."
Expected Result
<your systems ip>, something like '34.195.141.162'
Alternate Expected Result - You'll see this if you are blocked from external connections by your firewall (possibly what you're using the proxy to get avoid):
NOTE ...Connection timed out after 5 seconds.
  • Next, try using the proxy with curl + an external site that will return the found ip address.
Command
https_proxy="http://<proxyurl>:<proxyport>" curl https://canhazip.com --silent --connect-timeout 5 || echo "FAILED: With proxy, connection timed out after 5 seconds."
Example
https_proxy="http://masnes.testproxy.internal.lingoport.io:3128" curl https://canhazip.com --silent --connect-timeout 5 || echo "FAILED: With proxy, connection timed out after 5 seconds."
Expected Result
<proxy ip>, something different from the above. For the above example it was '54.205.127.98'. The connection should not fail.

If you're able to connect to the proxy via telnet, you're able to use the proxy to get your remote ip from https://canhazip.com, and if the result you get from https://canhazip.com via the proxy is different than without the proxy, then you are ready to proceed.

Defining the Proxy for use with LRM AWS Machine Translate

To set a proxy server, define the environment variable "https_proxy" prior to running LRM with AWS Machine Translation. Through Jenkins, the easiest way to do so is:

Manage Jenkins -> (Goes to a new page)
Configure System -> (Goes to a new page)
Global Properties -> Environment Variables -> Add (Button at the bottom of the Environment Variables settings)

Settings should be: Name: https_proxy Value: http://<yourproxy>:<yourproxyport>

Example https_proxy http://masnes.testproxy.internal.lingoport.io:3128

Validating the Proxy through Jenkins

You can add a step to your Jenkins Automation build(s) to confirm that the proxy is used. To do so:

  1. Start at the Jenkins HomePage
  2. Select the build you would like to test with. For example 'MyCompany.MyProject' -> (Goes to a new page)
  3. Go to Configure on the left -> (Goes to a new page)
  4. Scroll to the bottom of the Configure page. You should see an 'Add build step' button just above 'Post-build actions'
  5. Add build step -> Execute shell -> (An empty 'Execute shell' box should appear)
  6. In the box, add the following content:
set +e  # curl may fail without the proxy, depending on network configuration.
set +x  # optional setting. Don't show commands run, so output is clearer.
echo
echo "Validating Proxy is Used:"
echo
echo "Attempting connection without proxy. May timeout if network blocks traffic without proxy."
echo "Otherwise, should return the external ip of the system."
echo -n "IP returned: "
https_proxy="" curl https://canhazip.com --silent --connect-timeout 5 || echo "NOTE: Without proxy, connection timed out after 5 seconds."
echo
echo "Attempting connection with proxy. Proxy is valid if connection succeeds."
echo "Should return the external ip of the proxy server."
echo "    details: https_proxy set to: $https_proxy"
echo -n "IP returned: "
curl "https://canhazip.com" --silent --connect-timeout 5 || echo "FAILED: With the proxy set, connection timed out after 5 seconds."
echo
echo
  1. After you have filled it out, drag and drop this box so that it is moved higher, above any other boxes such as 'Update Dashboard' or 'L10n Vendor'. This way it runs first.
  2. Save the build. Then run it. Navigate to the console output of the build. You should see a section that shows:
Validating Proxy is Used:

Attempting connection without proxy. May timeout if network blocks traffic without proxy.
Otherwise, should return the external ip of the system.
IP returned: 34.195.141.162

Attempting connection with proxy. Proxy is valid if connection succeeds.
Should return the external ip of the proxy server.
    details: https_proxy set to: http://masnes.testproxy.internal.lingoport.io:3128
IP returned: 54.205.127.98