Use to build your own HTTP Proxy

Original link:

If you need to develop a cluster and need to access the intranet during the development process, a common way is to establish a virtual private network. But if you are unwilling to establish a virtual private network, then a relatively simple way is to establish a layer of HTTP Proxy to access the data in the intranet. By configuring HTTP Proxy on the computer, you can use the corresponding node to access specific web pages and solve the problem of HTTP access.


The principle of HTTP Proxy Server is not complicated, it is a standard forward proxy. You only need to be able to build such a service.


Actual operation logic

The following article uses Debian GNU/Linux 10 as an example

1. Install Python3 & pip 3 on your node

Python3 is the runtime environment for running , and pip3 is the tool for installing . Execute the following command to install.

 apt install python3 python3-pip

2. Install

Here we do not use Virtual Env to install, mainly to facilitate the subsequent addition of Systemd for control. If you are used to using Supervisord for control, you can use Virtual Env to install . Execute the following command

 pip3 install

3. Start Proxy for testing

Execute the following command on your node to start a test server.

 proxy --hostname

If you need to monitor a specific IP, modify to your specific IP.

After configuration, you can see the following output, indicating that the proxy server has been successfully started.

After the startup is complete, you can access the following commands to test locally.

 curl -x [服务器IP]:8899

When you see the following output, confirm whether the origin in the returned value is your node IP. If it is your node IP, it means that your HTTP Proxy has been configured successfully. Later, you can access it through this HTTP Proxy.

After the test is complete, you can execute Ctrl + C to close the current Proxy Server.

4. Configure Basic Auth Authentication

The HTTP Proxy Server is configured above, but one problem is that this Server has no security verification and will be used by others at any time. So we need to configure some basic security configuration to solve this problem.

Add the –basic-auth option to your to add basic authentication. The user passwords are separated by colons. For example, if I need to create a proxy whose username is admin and whose password is also admin, I can execute the following command.

 proxy --hostname --basic-auth admin:admin

5. Configure boot auto-start

Now Auth is also available, but we can’t always open Terminal to run our service, so a good way is to add Systemd to it, so that we can use the system’s own capabilities to complete the self-starting of Proxy.

Execute systemctl edit --force --full proxy.service to create a new Systemd service, add the following code and save it.

 [Unit]Description=Proxy[Service]ExecStartPre=/bin/sleep 10ExecStart=proxy --hostname --basic-auth admin:adminRestart=always[Install]

After saving, execute systemctl enable proxy.service configure the server’s self-start at boot & systemctl start proxy.service to realize the self-start of the Proxy service and start the service at the current time.


With HTTP Proxy, you can access servers in the intranet in a simpler way. You only need to control the access rights of the Proxy node, and you can handle the security of intranet data very well.

This article is reprinted from:
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment

Your email address will not be published.