Use R With a Proxy

If you have a proxy in your organization to connect to the Internet, you may need to change some settings so that R can also access the Internet.

R uses the following default environment variables to work with a proxy:

  • HTTP_PROXY: The complete address of the proxy, used to connect to the Internet. For example: http://IP_PROXY:80.

  • HTTPS_PROXY: The complete address of the proxy, used for the https protocol. Usually, the address used is the same as the one used for the HTTP_PROXY environment variable.

  • NO_PROXY: The list of URLs that will not use the proxy. If you need to access another machine inside the platform, the URL or IP must be listed here.

    • If you are using an IP address, you can use the wildcard. For example : 192.168.25.*

    • If you are using a URL, you must write the full URL between the https:// and the next slash /.

Edit Job Variables

To edit these variables for jobs, refer to the Editing Environment Variables tutorial.
Once modified, the variables will be updated for any new job started.

Edit App Variables

To edit these variables for apps, you can either:

  • Restart the Docker container before applying your changes.

  • Use the following R lines of code to change variables instantly:

    # The list of exceptions to add.
    ips <- c('192.168.25.*', '1-random-dockerurl.public.saagie.com')
    
    sapply(ips, function(ip) { # For each IP in the list.
     if(!stringi::stri_detect_fixed(Sys.getenv('NO_PROXY'), ip)) { # If the variable is not already present.
     Sys.setenv('NO_PROXY'=paste(Sys.getenv('NO_PROXY'),ip, sep = ','))}}) # Add it to the existing environment variable.

    You will have to run these lines of code every time you restart your app.