Κοινή χρήση μέσω


Configure a proxy server

APPLIES TO: Composer v2.x

When running Composer in a private network, access to external resources, for example on the internet, might be forbidden by the network security settings. This article describes how to configure a proxy server to allow Composer to access those resources.

The following figure is a simplified representation of the environment where Composer (client) runs when in a private network and behind a firewall.

composer proxy context

To avoid being blocked by the firewall, Composer needs to use a proxy server to access the internet.

A proxy server is an application that acts as an intermediary between a client and a server providing a resource. The client directs the request to the proxy server, which evaluates the request and performs the required network transaction. The proxy server may also provide other services, such as load balancing and security.

Prerequisites

  1. Composer 2.1 or later.

  2. The proxy server IP address and port provided by your IT administrator.

  3. The firewall configured and the proxy server running on the internal network, performed by your IT administrator.

    Note

    For testing purposes only, see the Set up a test proxy server section.

To configure Composer to use the proxy server, you must:

  • Configure the system proxy server to route the requests issued by Composer.
  • Configure the environment where Composer runs to enable the use of the proxy server when sending HTTP requests.

Configure Composer environment

To configure the environment in which Composer runs, set both the system proxy and environment variables to account for differences in browser behavior.

Configure the system proxy

In Control Panel, select Network & Internet and then select Manual proxy setup. Set the proxy IP address and port, using the values provided by your IT administrator. Make sure that the proxy doesn't apply to localhost.

Configure environment variables

  1. Open a console window and change to the directory where Composer is installed.

  2. Set the environment variables as shown below.

    set https_proxy=<your proxy server IP address>:<your port number>
    set http_proxy=<your proxy server IP address>:<your port number>
    set no_proxy=localhost
    

    The last setting is necessary because Composer runs at this location: http://localhost:5000.

    You can now run Composer from the command line.

If the proxy server isn't enabled by your IT administrator, Composer runs with limited capabilities.

Set up a test proxy server

The steps described in this section are for testing purposes only.

  1. Open a console window.

  2. Create a myProxy directory.

  3. Change to the myProxy directory and use npm init to create a package.json file:

    npm init
    

    The command will prompt you for information to add to the file. For descriptions of the properties it asks for, see npm's package.json documentation. Here is a sample package.json file.

    {
      "name": "myproxy",
      "version": "1.0.0",
      "description": "test",
      "main": "index.js",
      "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1"
      },
      "author": "<author-name>",
      "license": "ISC"
    }
    
  4. Run the following command:

    npm install proxy
    
  5. Create the file index.js and enter the following code:

    var http = require('http');
    var setup = require('proxy');
    var server = setup(http.createServer());
    server.listen(3128, function () {
        var port = server.address().port;
        console.log('HTTP(s) proxy server listening on port %d', port);
    });
    
  6. Run the following command:

    node index.js
    

    You should get a message saying that the proxy is listening on port 3128.

Test your proxy configuration

  1. In a console window, verify the IPv4 address of your machine network interface by running the ipconfig command

    ipconfig
    

    Check with your IT administrator that both the IPv4 address and the port number used to configure the proxy are correct.

  2. Enable the use of the proxy on your machine as described in the Configure the system proxy section.

  3. In another command terminal, switch to the directory where the Composer executable is located.

  4. Set the environment variables as described in the Configure environment variables section.

  5. Finally, run Composer. Composer should be fully functional with access to resources on the internet and full templates selection. This proves that Composer is using the proxy server you configured.

Next steps

In this article, you learned how to enable Composer proxy server for your preferred OS. Next, learn how to build your first Bot with Composer.