Difference between revisions of "LRM Proxy Configuration"

From Lingoport Wiki
Jump to: navigation, search
(SFTP)
 
(13 intermediate revisions by the same user not shown)
Line 4: Line 4:
   
 
<code>export _JAVA_OPTIONS="-Dhttp.proxyHost=some.url.here -Dhttp.proxyPort=3128 -Dhttps.proxyHost=some.url.here -Dhttps.proxyPort=3128 -Dftp.proxyHost=some.url.here -Dftp.proxyPort=3128"</code>
 
<code>export _JAVA_OPTIONS="-Dhttp.proxyHost=some.url.here -Dhttp.proxyPort=3128 -Dhttps.proxyHost=some.url.here -Dhttps.proxyPort=3128 -Dftp.proxyHost=some.url.here -Dftp.proxyPort=3128"</code>
  +
Ugi0sZpFVHD0
 
  +
* The url should '''''not''''' include the preceeding 'http://' or 'www'
 
== Notes on the JAVA_OPTIONS setting ==
 
* The url should not include the preceeding 'http://' or 'www'
 
 
** Good
 
** Good
 
*** internet.proxy.yourcompany.com
 
*** internet.proxy.yourcompany.com
Line 35: Line 33:
 
* Add the following line somewhere in the file
 
* Add the following line somewhere in the file
 
** <code>export _JAVA_OPTIONS="-Dhttp.proxyHost=some.url.here -Dhttp.proxyPort=3128 -Dhttps.proxyHost=some.url.here -Dhttps.proxyPort=3128 -Dftp.proxyHost=some.url.here -Dftp.proxyPort=3128"</code>
 
** <code>export _JAVA_OPTIONS="-Dhttp.proxyHost=some.url.here -Dhttp.proxyPort=3128 -Dhttps.proxyHost=some.url.here -Dhttps.proxyPort=3128 -Dftp.proxyHost=some.url.here -Dftp.proxyPort=3128"</code>
  +
*** Replace 3128 with the port number appropriate for your proxy.
   
 
=== System Config ===
 
=== System Config ===
Line 42: Line 41:
 
* Add the following line to the file and save it:
 
* Add the following line to the file and save it:
 
** <code>export _JAVA_OPTIONS="-Dhttp.proxyHost=some.url.here -Dhttp.proxyPort=3128 -Dhttps.proxyHost=some.url.here -Dhttps.proxyPort=3128 -Dftp.proxyHost=some.url.here -Dftp.proxyPort=3128"</code>
 
** <code>export _JAVA_OPTIONS="-Dhttp.proxyHost=some.url.here -Dhttp.proxyPort=3128 -Dhttps.proxyHost=some.url.here -Dhttps.proxyPort=3128 -Dftp.proxyHost=some.url.here -Dftp.proxyPort=3128"</code>
  +
*** Replace 3128 with the port number appropriate for your proxy.
  +
  +
= Proxy Verification =
  +
  +
To avoid extensive troubleshooting, it is important to confirm that proxy settings are correct. Perform the following tests to verify:
  +
  +
== HTTP/HTTPS ==
  +
  +
HTTP/HTTPS connectivity can be confirmed using curl. Curl respects the environment variables 'http_proxy' and 'https_proxy'.
  +
  +
To set these variables for a single session, type the following into the terminal:
  +
  +
$ export http_proxy="internet.proxy.yourcompany.com:3128"
  +
$ export https_proxy="internet.proxy.yourcompany.com:3128"
  +
  +
To keep these variables between sessions, add the above lines to your bash configuration file, $HOME/.bashrc.
  +
  +
To test a connection:
  +
  +
<code>$ curl globalyzer.com</code>
  +
  +
'''Expected output:'''
  +
  +
<html>
  +
<head>
  +
<title>globalyzer.com</title>
  +
<meta http-equiv="Refresh" content="1;URL=/gzserver/">
  +
<meta http-equiv="content-language" content="en-us" />
  +
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
  +
<meta name="description" content="Globalyzer server">
  +
</head>
  +
<body>
  +
</body>
  +
</html>
  +
</code>
  +
  +
'''Failure if:'''
  +
  +
Command hangs for > 10 seconds. In this case, you can cancel it with Ctrl-C.
  +
  +
'''Note:''' By default, environment variables like 'http_proxy' are not kept when using sudo. So 'sudo curl globalyzer.com' will fail even if http_proxy is set. To keep environment variables with sudo, use the following format, including the '"':
  +
$ sudo -E bash -c "Type your command here"
  +
  +
== SFTP ==
  +
  +
You can verify SFTP connectivity using the <code>sftp</code> command along with <code>-o ProxyCommand=</code> as follows.
  +
  +
You will first need to install the 'nc' command:
  +
  +
$ export http_proxy="internet.proxy.yourcompany.com:3128"
  +
$ export https_proxy="$http_proxy"
  +
$ sudo -E bash -c "yum install nc"
  +
  +
You can then use it to perform the proxy work with the sftp command:
  +
  +
$ sftp -o "ProxyCommand=/usr/bin/nc --proxy internet.proxy.company.com:3128 %h %p" username@your.ftp.server
  +
  +
You will need to change:
  +
* <code>internet.proxy.company.com</code> to your proxy
  +
* <code>3128</code> to your proxy port (keep the ':')
  +
* <code>username</code> to a username authorized to access the ftp server
  +
* <code>your.ftp.server</code> to the ftp server url.
  +
  +
'''Expected output:'''
  +
  +
The should return quickly with some output. Ideally this should be either a password prompt or a console that allows you to navigate the ftp server. If the login fails you may get a 403 message - this is not a proxy issue.
  +
  +
'''Failure if:'''
  +
  +
Command hangs for > 10 seconds. In this case, you can cancel it with Ctrl-C.

Latest revision as of 20:47, 22 August 2017

LRM Proxy Configuration

To use LRM through a proxy, you will need to set java proxy settings before executing the LRM jar file. To set java proxy settings, configure the shell to have a '_JAVA_OPTIONS' variable with the proxy settings listed. Like so:

export _JAVA_OPTIONS="-Dhttp.proxyHost=some.url.here -Dhttp.proxyPort=3128 -Dhttps.proxyHost=some.url.here -Dhttps.proxyPort=3128 -Dftp.proxyHost=some.url.here -Dftp.proxyPort=3128" Ugi0sZpFVHD0

Adding Java Options

_JAVA_OPTIONS may be added to the following locations:

Jenkins Config

This will affect LRM when run through Jenkins.

  • In Jenkins, select 'Manage Jenkins' then 'Configure System'.
  • Under 'Global properties' ensure that 'Environment variables' is checked.
  • At the bottom of the Environment variables section, there will be a button 'Add' to add new environment variables.
  • Name: _JAVA_OPTIONS
  • Value: -Dhttp.proxyHost=some.url.here -Dhttp.proxyPort=3128 -Dhttps.proxyHost=some.url.here -Dhttps.proxyPort=3128 -Dftp.proxyHost=some.url.here -Dftp.proxyPort=3128
    • Replace 3128 with the port number appropriate for your proxy.

User Config

This will affect LRM commands run at the command prompt for a specific user. It will also affect other java programs run at the command prompt by this user. May not affect commands run within Jenkins builds.

  • Edit $HOME/.bashrc
    • $ vim $HOME/.bashrc
  • Add the following line somewhere in the file
    • export _JAVA_OPTIONS="-Dhttp.proxyHost=some.url.here -Dhttp.proxyPort=3128 -Dhttps.proxyHost=some.url.here -Dhttps.proxyPort=3128 -Dftp.proxyHost=some.url.here -Dftp.proxyPort=3128"
      • Replace 3128 with the port number appropriate for your proxy.

System Config

This will affect all users on the system. All java commands run at the command prompt will use the configured proxy settings. May not affect commands run within Jenkins builds.

  • Create a file /etc/profile.d/custom.sh
    • sudo vim /etc/profile.d/custom.sh
  • Add the following line to the file and save it:
    • export _JAVA_OPTIONS="-Dhttp.proxyHost=some.url.here -Dhttp.proxyPort=3128 -Dhttps.proxyHost=some.url.here -Dhttps.proxyPort=3128 -Dftp.proxyHost=some.url.here -Dftp.proxyPort=3128"
      • Replace 3128 with the port number appropriate for your proxy.

Proxy Verification

To avoid extensive troubleshooting, it is important to confirm that proxy settings are correct. Perform the following tests to verify:

HTTP/HTTPS

HTTP/HTTPS connectivity can be confirmed using curl. Curl respects the environment variables 'http_proxy' and 'https_proxy'.

To set these variables for a single session, type the following into the terminal:

$ export http_proxy="internet.proxy.yourcompany.com:3128"
$ export https_proxy="internet.proxy.yourcompany.com:3128"

To keep these variables between sessions, add the above lines to your bash configuration file, $HOME/.bashrc.

To test a connection:

$ curl globalyzer.com

Expected output:

<html>
<head>
<title>globalyzer.com</title>
<meta http-equiv="Refresh" content="1;URL=/gzserver/">
<meta http-equiv="content-language" content="en-us" />
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta name="description" content="Globalyzer server">
</head>
<body>
</body>
</html>

Failure if:

Command hangs for > 10 seconds. In this case, you can cancel it with Ctrl-C.

Note: By default, environment variables like 'http_proxy' are not kept when using sudo. So 'sudo curl globalyzer.com' will fail even if http_proxy is set. To keep environment variables with sudo, use the following format, including the '"':

$ sudo -E bash -c "Type your command here"

SFTP

You can verify SFTP connectivity using the sftp command along with -o ProxyCommand= as follows.

You will first need to install the 'nc' command:

$ export http_proxy="internet.proxy.yourcompany.com:3128"
$ export https_proxy="$http_proxy"
$ sudo -E bash -c "yum install nc"

You can then use it to perform the proxy work with the sftp command:

$ sftp -o "ProxyCommand=/usr/bin/nc --proxy internet.proxy.company.com:3128 %h %p" username@your.ftp.server

You will need to change:

  • internet.proxy.company.com to your proxy
  • 3128 to your proxy port (keep the ':')
  • username to a username authorized to access the ftp server
  • your.ftp.server to the ftp server url.

Expected output:

The should return quickly with some output. Ideally this should be either a password prompt or a console that allows you to navigate the ftp server. If the login fails you may get a 403 message - this is not a proxy issue.

Failure if:

Command hangs for > 10 seconds. In this case, you can cancel it with Ctrl-C.