Here is a guide for you on how to install and set up Envoy on Ubuntu. This will require a few steps, including downloading the software, setting it up, and ensuring it’s working correctly.

Before we begin, I assume you have a basic knowledge of Linux commands and are logged in as a user with sudo privileges.

Installation

  1. Update your system.

It’s always a good practice to update your Ubuntu system before installing new software. Run the following commands in your terminal:

sudo apt update
sudo apt upgrade

2. Install the necessary dependencies.

Envoy is built using Bazel. So, before you install Envoy, you’ll need to install Bazel and other dependencies:

sudo apt install curl gnupg2 clang-format-7 cmake automake autoconf libtool zlib1g-dev build-essential unzip virtualenv python3-dev python3-pip lcov bazel docker.io libunwind-dev

3. Get the Envoy source code.

You can clone the Envoy GitHub repository to get the source code:

git clone https://github.com/envoyproxy/envoy.git
cd envoy

4. Build Envoy.

Now you can build Envoy using Bazel. This process may take some time:

bazel build //source/exe:envoy-static

5. Test the build.

You can test if Envoy is correctly built using the following command:

bazel test //test/common/common/...

If everything is correctly set up, you should see the following:

Executed x out of y tests: z tests pass

Where x, y, and z are numbers.

6. Run Envoy.

After building and testing Envoy, you can now run it using the following command:

bazel-bin/source/exe/envoy-static -c configs/envoy.yaml

configs/envoy.yaml should be the path to your Envoy configuration file. If the command is successful, you should see an output that indicates Envoy is running. You can check this by visiting localhost:9901 on your browser (or localhost:port if you’ve configured a different port in your Envoy configuration file).

Configure Envoy as a reverse proxy

To use Envoy as a reverse proxy, follow the next steps. It includes creating a configuration file that defines how Envoy should route requests.

1. Update a configuration file.

Before you update your configuration file, you must decide on the settings you want for your reverse proxy. The configuration file tells Envoy where to direct incoming requests. It includes information such as the IP addresses and ports of your services.

An example of a simple configuration for a reverse proxy might look something like this:

static_resources:
  listeners:
  - address:
      socket_address:
        address: 0.0.0.0
        port_value: 9901
    filter_chains:
    - filters:
      - name: envoy.http_connection_manager
        typed_config:
          "@type": type.googleapis.com/envoy.config.filter.network.http_connection_manager.v2.HttpConnectionManager
          codec_type: AUTO
          stat_prefix: ingress_http
          route_config:
            name: local_route
            virtual_hosts:
            - name: backend
              domains:
              - "*"
              routes:
              - match:
                  prefix: "/"
                route:
                  cluster: web_service
          http_filters:
          - name: envoy.router
            typed_config: {}
  clusters:
  - name: web_service
    connect_timeout: 0.25s
    type: LOGICAL_DNS
    # Comment out the following line to test on v6 networks
    dns_lookup_family: V4_ONLY
    lb_policy: ROUND_ROBIN
    load_assignment:
      cluster_name: web_service
      endpoints:
      - lb_endpoints:
        - endpoint:
            address:
              socket_address:
                address: 127.0.0.1
                port_value: 8080
		

This configuration tells Envoy to accept incoming requests on port 9901 and route them to a service at 127.0.0.1:8080.

2. Save the configuration file.

Save the above YAML configuration into a file, e.g., envoy.yaml. You may need to adjust this configuration based on your needs.

3. Run Envoy with the configuration file.

Run the Envoy binary you’ve built and tested using the configuration file as an argument:

bazel-bin/source/exe/envoy-static -c envoy.yaml

Make sure to replace envoy.yaml with the path to your actual configuration file if it’s elsewhere.

4. Test your setup.

You can test if Envoy is working correctly by requesting the address and port you specified in your configuration file (for the example configuration above, you would ask http://localhost:9901). If Envoy works correctly, your request should be routed to your backend service.