Help Center> CodeArts Deploy> Best Practices> Deploying Tasks Using a Proxy Host
Updated on 2023-05-26 GMT+08:00

Deploying Tasks Using a Proxy Host

This section describes how to deploy an application on an intranet host or server using a proxy host.

Process

The Internet forward proxy function of Squid is used to specify the IP address and port of the target host on the proxy, enabling the target host to access the public network.

For more information about Squid, go to Squid official website. The following procedure uses a Linux host as an example.

Prerequisites

  • A host Proxy-B bound to a public IP address is available. If no proxy host is available, see Applying for an ECS.
  • A host (Host-A) not bound to a public IP address is available.
  • Proxy-B and Host-A can access each other through the intranet.

Procedure

  1. Install Squid.

    Access the command line tool of Proxy-B and run the following command:

    yum install squid -y

    If Complete is displayed, run the following command:

    yum install iptables-services 

    Enter Y. If Complete is displayed, the installation is complete.

  2. Edit the Squid configuration file.

    1. Access the command line tool of Proxy-B and run the following command:
      vim /etc/squid/squid.conf

    2. Add the following command to the position marked in the red box in the preceding figure:
      acl local src Internal IP address of the host/24
    3. Press Esc and enter :wq to save the file and exit.

  3. Configure the firewall of Proxy-B.

    Access the command line tool of Proxy-B and run the following commands in sequence:

    systemctl stop firewalld.service 
    systemctl disable firewalld.service
    yum install iptables-services iptables-devel -y
    systemctl enable iptables.service
    systemctl start iptables.service
    iptables -I INPUT 1 -s Internal IP address of the host/24 -p tcp --dport 3128 -j ACCEPT
    iptables -I INPUT 2 -p tcp --dport 3128 -j DROP 

    The IP address in the last but one line must be set to the internal IP address segment or IP address of Host-A. 3128 is the proxy port of Squid.

  4. Install OpenSSL.

    Access the command line tool of Proxy-B and run the following command:

    yum install openssl 

    If Complete is displayed, the installation is complete.

  5. Start Squid.

    Access the command line tool of Proxy-B and run the following command:

    systemctl start squid     //Start Squid.
    systemctl status squid    //Check the status of Squid.

  6. Configure the forward proxy.

    Access the command line tool of Host-A and run the following command:

    echo "export http_proxy=http://Internal IP address of the proxy host:3128" >>/etc/profile
    echo "export https_proxy=http://Internal IP address of the proxy host:3128" >>/etc/profile
    echo "export http_proxy=http://Internal IP address of the proxy host:3128" >>~/.bashrc
    echo "export https_proxy=http://Internal IP address of the proxy host:3128" >>~/.bashrc
    echo "export http_proxy=http://Internal IP address of the proxy host:3128" >>~/.bash_profile
    echo "export https_proxy=http://Internal IP address of the proxy host:3128" >>~/.bash_profile
    source /etc/profile
    source ~/.bashrc
    source ~/.bash_profile

  7. Creating basic resources.

    1. In the target project, choose Settings > General > Basic Resources. The Host Cluster page is displayed.
    2. Click Create Host Cluster, enter the following information, and click Save.

      Parameter

      Mandatory

      Description

      Cluster Name

      Yes

      Enter a user-defined host cluster name.

      OS

      Yes

      Select Linux based on the OS of the host to be added.

      Proxy Access

      Yes

      Enable the option.

      Execution host

      Yes

      A resource pool is a collection of physical environments where deployment commands are executed during software package deployment. In this scenario, the execution host uses an official resource pool.

      Description

      No

      Enter the description of the host cluster.

    3. Click Create Proxy Host, enter the following information, and click OK.
      Table 1 Parameters of the proxy host in the Linux operating system

      Parameter

      Mandatory

      Description

      Host Name

      Yes

      Enter a user-defined proxy host name, for example, proxy host-B.

      IP

      Yes

      Enter the public IP address bound to proxy Host-B.

      OS

      Yes

      Keep the default value because it is the OS of your host cluster.

      Authorization

      Yes

      In this scenario, the password is used for authentication. Enter the username and password of Proxy-B.

      SSH Port

      Yes

      Port 22 is recommended.

    4. Click Add Target Host, enter the following information, and click OK.
      Table 2 Parameters of the target host running the Linux operating system

      Parameter

      Mandatory

      Description

      Host Name

      Yes

      Enter the user-defined name of the target host, for example, Host-A.

      Proxy Hosts

      Yes

      Select Proxy host-B as the network proxy for the target host that cannot connect to the public network.

      IP

      Yes

      Enter the private IP address of deployment host -A.

      OS

      Yes

      Keep the default value because it is the OS of your host cluster.

      Authorization

      Yes

      In this scenario, the password is used for authentication. Enter the username and password of Host-A.

      SSH Port

      Yes

      Port 22 is recommended.

    5. Click in the Operation column of a host to start the host for connectivity verification.

  8. Create an application.

    1. Log in to the CodeArts homepage and click the target project name to access the project.
    2. Choose CICD > Deploy.
    3. Click Create Application. On the Set Basic Information page that is displayed, modify the basic information such as App Name, Description, and Execution Resource Pool as required.
    4. After editing the basic application information, click Next. On the deployment template selection page that is displayed, select Blank Template and click OK.
    5. On the Deployment Actions tab page, find the right list, click Add to add a target action to the orchestration area.
    6. On the Environment Mgmt page, click Create Environment, enter basic environment information, and click Save.
    7. Click Import Host. The system automatically filters all clusters that meet the requirements of the current environment. In the dialog box that is displayed, select the target host cluster and import Proxy-B and Host-A to the environment.

    Set the OS of the host group to Linux.

  9. Deploy the application. For details, see Managing applications.