没有不值得去解决的问题,也没有不值得去学习的技术!

How to Implement HTTP Requests to Google and YouTube After Installing V2Ray on Alibaba Cloud Mainland China ECS CentOS 7.x

Test the Alibaba Cloud server making curl HTTP requests to http://httpbin.org/ip, https://www.google.com, and https://www.youtube.com. The connection is successful

1. To list all version information, run the command: lsb_release -a. Version: CentOS 7.7. See Figure 1.

List all version information, run the command: lsb_release -a. Version: CentOS 7.7.
Figure 1
Plaintext
[root@iZ23wv7v5ggZ ~]# lsb_release -a
LSB Version:    :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description:    CentOS Linux release 7.7.1908 (Core)
Release:        7.7.1908
Codename:       Core
[root@iZ23wv7v5ggZ ~]#


2. Check the bash version: 4.2.46. See Figure 2.

Check the bash version: 4.2.46
Figure 2
Plaintext
[root@iZ23wv7v5ggZ bin]# bash --version
GNU bash, version 4.2.46(2)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
[root@iZ23wv7v5ggZ bin]# ^C
[root@iZ23wv7v5ggZ bin]#


3. Install and update V2Ray. Reference URL: https://github.com/v2fly/fhs-install-v2ray/blob/master/README.zh-Hans-CN.md . See Figure 3.

Install and update V2Ray. Reference URL: https://github.com/v2fly/fhs-install-v2ray/blob/master/README.zh-Hans-CN.md
Figure 3
Plaintext
[root@iZ23wv7v5ggZ ~]# bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh)
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 21613  100 21613    0     0  21964      0 --:--:-- --:--:-- --:--:-- 21964
info: Installing V2Ray v4.40.1 for x86_64
Downloading V2Ray archive: https://github.com/v2fly/v2ray-core/releases/download/v4.40.1/v2ray-linux-64.zip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   626  100   626    0     0    734      0 --:--:-- --:--:-- --:--:--   733
100 12.3M  100 12.3M    0     0  2996k      0  0:00:04  0:00:04 --:--:-- 4167k
Downloading verification file for V2Ray archive: https://github.com/v2fly/v2ray-core/releases/download/v4.40.1/v2ray-linux-64.zip.dgst
info: Extract the V2Ray package to /tmp/tmp.Kbb2Sg6CcW and prepare it for installation.
rm: cannot remove ‘/etc/systemd/system/v2ray.service.d/10-donot_touch_multi_conf.conf’: No such file or directory
rm: cannot remove ‘/etc/systemd/system/v2ray@.service.d/10-donot_touch_multi_conf.conf’: No such file or directory
info: Systemd service files have been installed successfully!
warning: The following are the actual parameters for the v2ray service startup.
warning: Please make sure the configuration file path is correctly set.
~~~~~~~~~~~~~~~~
[Unit]
Description=V2Ray Service
Documentation=https://www.v2fly.org/
After=network.target nss-lookup.target

[Service]
User=nobody
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
NoNewPrivileges=true
ExecStart=/usr/local/bin/v2ray -config /usr/local/etc/v2ray/config.json
Restart=on-failure
RestartPreventExitStatus=23

[Install]
WantedBy=multi-user.target
# In case you have a good reason to do so, duplicate this file in the same directory and make your customizes there.
# Or all changes you made will be lost!  # Refer: https://www.freedesktop.org/software/systemd/man/systemd.unit.html
[Service]
ExecStart=
ExecStart=/usr/local/bin/v2ray -config /usr/local/etc/v2ray/config.json
~~~~~~~~~~~~~~~~
warning: The systemd version on the current operating system is too low.
warning: Please consider to upgrade the systemd or the operating system.

installed: /usr/local/bin/v2ray
installed: /usr/local/bin/v2ctl
installed: /usr/local/share/v2ray/geoip.dat
installed: /usr/local/share/v2ray/geosite.dat
installed: /usr/local/etc/v2ray/config.json
installed: /var/log/v2ray/
installed: /var/log/v2ray/access.log
installed: /var/log/v2ray/error.log
installed: /etc/systemd/system/v2ray.service
installed: /etc/systemd/system/v2ray@.service
removed: /tmp/tmp.Kbb2Sg6CcW
info: V2Ray v4.40.1 is installed.
You may need to execute a command to remove dependent software: yum remove curl unzip
Please execute the command: systemctl enable v2ray; systemctl start v2ray
[root@iZ23wv7v5ggZ ~]# systemctl enable v2ray
Created symlink from /etc/systemd/system/multi-user.target.wants/v2ray.service to /etc/systemd/system/v2ray.service.
[root@iZ23wv7v5ggZ ~]# systemctl start v2ray
[root@iZ23wv7v5ggZ ~]#



4. I purchased a commercial V2RAY server, GetSS, selected an Azure server in Hong Kong, and copied the URL. The value is no longer valid, as I have modified it. See Figure 4.

I purchased a commercial V2RAY server, GetSS, selected an Azure server in Hong Kong, and copied the URL
Figure 4
Plaintext
vmess://eyJhZGQiOiJoazAxLmdldHNzLnRvcCIsImhvc3QiOiIiLCJpZCI6IjRBNjMzOEU0LTI3RDItQkQ5My01MUI1LUIzQjIxRUEwM0JFMiIsIm5ldCI6InRjcCIsInBhdGgiOiIiLCJwb3J0IjoiMjM0NTYiLCJ5wcyI6IkhLLUhLVC14MCIsInRscy66I6IiIsInYiOjIsImFpZCI6MCwidHlwZSI6Im5vbmUifQ==

5. After Base64 decoding the value following vmess://, format it as JSON, resulting in the following values. This will be used later to configure the V2RAY client on the Alibaba Cloud server. The value is no longer valid, as I have modified it. See Figure 5.

After Base64 decoding the value following vmess://, format it as JSON, resulting in the following values. This will be used later to configure the V2RAY client on the Alibaba Cloud server
Figure 5
JSON
{
  "add": "hk01.getss.top",
  "host": "",
  "id": "4A6338E4-27D2-BD93-515B5-B3B21EA6603BE2",
  "net": "tcp",
  "path": "",
  "port": "23456",
  "ps": "HK-HKT-x0",
  "tls": "",
  "v": 2,
  "aid": 0,
  "type": "none"
}

6. View the file /usr/local/etc/v2ray/config.json; its value is an empty object.

Plaintext

[root@iZ23wv7v5ggZ ~]# cat /usr/local/etc/v2ray/config.json
{}
[root@iZ23wv7v5ggZ ~]#


7. V2Ray does not use the conventional C/S (client/server) architecture of proxy software; it can function either as a server or as a client. To configure the client, refer to the file: C:\Users\Administrator\AppData\Roaming\GetSS\config.json. GetSS is the Windows client. Edit /usr/local/etc/v2ray/config.json. See Figure 6.

V2Ray does not use the conventional C/S (client/server) architecture of proxy software; it can function either as a server or as a client. To configure the client, refer to the file: C:\Users\Administrator\AppData\Roaming\GetSS\config.json. GetSS is the Windows client. Edit /usr/local/etc/v2ray/config.json
Figure 6
JSON
{
    "policy": {
        "levels": {
            "0": {
                "uplinkOnly": 0
            }
        }
    },
    "inbound": {
        "listen": "127.0.0.1",
        "port": 1081,
        "protocol": "socks",
        "settings": {
            "auth": "noauth",
            "udp": false,
            "ip": "127.0.0.1"
        }
    },
    "inboundDetour": [
        {
            "listen": "127.0.0.1",
            "allocate": {
                "strategy": "always",
                "refresh": 5,
                "concurrency": 3
            },
            "port": 8001,
            "protocol": "http",
            "tag": "httpDetour",
            "domainOverride": [
                "http",
                "tls"
            ],
            "streamSettings": {},
            "settings": {
                "timeout": 0
            }
        }
    ],
    "log": {
        "loglevel": "warning"
    },
    "dns": {
        "servers": [
            "223.5.5.5"
        ]
    },
    "outboundDetour": [
        {
            "protocol": "freedom",
            "tag": "direct",
            "settings": {}
        }
    ],
    "outbound": {
        "sendThrough": "0.0.0.0",
        "mux": {
            "enabled": false,
            "concurrency": 8
        },
        "protocol": "vmess",
        "settings": {
            "vnext": [
                {
                    "address": "hk01.getss.top",
                    "port": 23456,
                    "users": [
                        {
                            "id": "4A6338E4-27D2-BD5593-51B5-B3B21EA03BE2",
                            "alterId": 0,
                            "security": "auto",
                            "level": 0
                        }
                    ],
                    "remark": "HK-HKT-x0"
                }
            ]
        },
        "streamSettings": {
            "wsSettings": {
                "path": "",
                "headers": {
                    "Host": ""
                }
            },
            "tcpSettings": {
                "header": {
                    "type": "none"
                }
            },
            "security": "",
            "tlsSettings": {
                "serverName": "",
                "allowInsecure": false
            },
            "httpSettings": {
                "path": "",
                "host": [
                    ""
                ]
            },
            "kcpSettings": {
                "header": {
                    "type": "none"
                },
                "mtu": 1350,
                "congestion": false,
                "tti": 20,
                "uplinkCapacity": 5,
                "writeBufferSize": 1,
                "readBufferSize": 1,
                "downlinkCapacity": 20
            },
            "network": "tcp"
        }
    }
}

8. Use the configuration check feature (the test option) provided by V2Ray, because it can detect issues beyond JSON syntax errors—for instance, if your hand slips and you accidentally type vmss instead of vmess, it will catch it immediately. If there are no problems with the configuration file, the output will look like this.

Plaintext
[root@iZ23wv7v5ggZ ~]# /usr/local/bin/v2ray -test -config /usr/local/etc/v2ray/config.json
V2Ray 4.40.1 (V2Fly, a community-driven edition of V2Ray.) Custom (go1.16.5 linux/amd64)
A unified platform for anti-censorship.
Configuration OK.
[root@iZ23wv7v5ggZ ~]# 

9. The authentication of the VMess protocol is time-based, so you must ensure that the system time difference between the server and the client is within 90 seconds. Check the system time of the Alibaba Cloud server.

Plaintext
[root@iZ23wv7v5ggZ ~]# date
Thu Jun 24 16:50:13 CST 2021
[root@iZ23wv7v5ggZ ~]# 

10. The actual packet flow is: {Browser} <–(socks)–> {V2Ray client inbound <-> V2Ray client outbound} <–(VMess)–> {V2Ray server inbound <-> V2Ray server outbound} <–(Freedom)–> {Target website}.

11. Check the ports linked to the proxy port 1081. Display all active sockets.

Plaintext
[root@iZ23wv7v5ggZ ~]# netstat -nat | grep 1081 -a
tcp6       0      0 :::1080                 :::*                    LISTEN     
[root@iZ23wv7v5ggZ ~]# 

12. Test the Alibaba Cloud server making HTTP requests to http://httpbin.org/ip, https://www.google.com, and https://www.youtube.com via socks. The connection is successful. See Figure 7.

Test the Alibaba Cloud server making HTTP requests to http://httpbin.org/ip, https://www.google.com, and https://www.youtube.com via socks. The connection is successful
Figure 7
Plaintext
[root@iZ23wv7v5ggZ v2ray]# curl --socks5 127.0.0.1:1081 http://httpbin.org/ip
{
  "origin": "14.192.49.13"
}
[root@iZ23wv7v5ggZ v2ray]# curl --socks5 127.0.0.1:1081 http://www.google.com
curl: (52) Empty reply from server
[root@iZ23wv7v5ggZ v2ray]# curl --socks5 127.0.0.1:1081 https://www.google.com
curl: (51) Unable to communicate securely with peer: requested domain name does not match the server's certificate.
[root@iZ23wv7v5ggZ v2ray]# curl -v --socks5 127.0.0.1:1081 https://sitekit.withgoogle.com
* About to connect() to proxy 127.0.0.1 port 1081 (#0)
*   Trying 127.0.0.1...
* 216
* 58
* 200
* 49
* Connected to 127.0.0.1 (127.0.0.1) port 1081 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* SSL connection using TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
* Server certificate:
*       subject: CN=*.appspot.com,O=Google LLC,L=Mountain View,ST=California,C=US
*       start date: May 31 01:07:40 2021 GMT
*       expire date: Aug 23 01:07:39 2021 GMT
*       common name: *.appspot.com
*       issuer: CN=GTS CA 1O1,O=Google Trust Services,C=US
> GET / HTTP/1.1
> User-Agent: curl/7.29.0
> Host: sitekit.withgoogle.com
> Accept: */*
> 
< HTTP/1.1 200 OK
< Content-Type: text/html; charset=utf-8
< Vary: Accept-Encoding
< X-Cloud-Trace-Context: f0ad2afe1e1be1a7fd9d592b1b2e4c62
< Date: Fri, 25 Jun 2021 09:35:19 GMT
< Server: Google Frontend
< Content-Length: 89089
< Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
< 

[root@iZ23wv7v5ggZ ~]# curl -v --socks5 127.0.0.1:1081 https://www.youtube.com
* About to connect() to proxy 127.0.0.1 port 1081 (#0)
*   Trying 127.0.0.1...
* 172
* 217
* 160
* 110
* Connected to 127.0.0.1 (127.0.0.1) port 1081 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* SSL connection using TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
* Server certificate:
*       subject: CN=*.google.com,O=Google LLC,L=Mountain View,ST=California,C=US
*       start date: May 31 01:35:44 2021 GMT
*       expire date: Aug 23 01:35:43 2021 GMT
*       common name: *.google.com
*       issuer: CN=GTS CA 1O1,O=Google Trust Services,C=US
> GET / HTTP/1.1
> User-Agent: curl/7.29.0
> Host: www.youtube.com
> Accept: */*
> 
< HTTP/1.1 200 OK
< Content-Type: text/html; charset=utf-8
< X-Content-Type-Options: nosniff
< Cache-Control: no-cache, no-store, max-age=0, must-revalidate
< Pragma: no-cache
< Expires: Mon, 01 Jan 1990 00:00:00 GMT
< Date: Mon, 28 Jun 2021 11:09:13 GMT
< X-Frame-Options: SAMEORIGIN
< Strict-Transport-Security: max-age=31536000
< permissions-policy: ch-ua-full-version=*, ch-ua-platform=*, ch-ua-platform-version=*, ch-ua-arch=*, ch-ua-model=*
< P3P: CP="This is not a P3P policy! See http://support.google.com/accounts/answer/151657?hl=en for more info."
< Server: ESF
< X-XSS-Protection: 0
< Set-Cookie: GPS=1; Domain=.youtube.com; Expires=Mon, 28-Jun-2021 11:39:13 GMT; Path=/; Secure; HttpOnly
< Set-Cookie: YSC=Mpx-P60pfFM; Domain=.youtube.com; Path=/; Secure; HttpOnly; SameSite=none
< Set-Cookie: VISITOR_INFO1_LIVE=I25nZHCzTQA; Domain=.youtube.com; Expires=Sat, 25-Dec-2021 11:09:13 GMT; Path=/; Secure; HttpOnly; SameSite=none
< Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
< Accept-Ranges: none
< Vary: Accept-Encoding
< Transfer-Encoding: chunked
< 
var ytcfg={d:function(){return window.yt&&yt.config_||ytcfg.data_||(ytcfg.data_={})},get:function(k,o){return k in ytcfg.d()?ytcfg.d()[k]:o},set:function(){var a=arguments;if(a.length>1)ytcfg.d()[a[0]]=a[1];else for(var k in a[0])ytcfg.d()[k]=a[0][k]}}; 

</pre>

13. The Alibaba Cloud server’s open ports 1081 and 8118 need to be opened by running commands. Open the iptables firewall. See Figure 8.

The Alibaba Cloud server's open ports 1081 and 8118 need to be opened by running commands. Open the iptables firewall
Figure 8
Plaintext
[root@iZ23wv7v5ggZ ~]# cat /etc/sysconfig/iptables
# Generated by iptables-save v1.4.21 on Mon Jun 28 19:53:18 2021
*filter
:INPUT DROP [2:80]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [247:63813]
:syn-flood - [0:0]
-A INPUT -p tcp -m tcp --dport 8118 -m state --state NEW -j ACCEPT
-A INPUT -p tcp -m tcp --dport 1081 -m state --state NEW -j ACCEPT
-A INPUT -p tcp -m tcp --dport 1080 -m state --state NEW -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 20000:30000 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT
-A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT
COMMIT
# Completed on Mon Jun 28 19:53:18 2021
[root@iZ23wv7v5ggZ v2ray]# iptables -I INPUT -p tcp --dport 1081 -m state --state NEW -j ACCEPT
[root@iZ23wv7v5ggZ v2ray]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[  OK  ]
[root@iZ23wv7v5ggZ v2ray]# cat /etc/sysconfig/iptables
# Generated by iptables-save v1.4.21 on Fri Jun 25 17:19:08 2021
*filter
:INPUT DROP [2:80]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [580:261280]
:syn-flood - [0:0]
-A INPUT -p tcp -m tcp --dport 1081 -m state --state NEW -j ACCEPT
-A INPUT -p tcp -m tcp --dport 1080 -m state --state NEW -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 20000:30000 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT
-A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT
COMMIT
# Completed on Fri Jun 25 17:19:08 2021
[root@iZ23wv7v5ggZ v2ray]# 

14. Install and configure Privoxy, and modify the configuration file /etc/privoxy/config. See Figure 9.

Install and configure Privoxy, and modify the configuration file /etc/privoxy/config
Figure 9
Plaintext
/usr/local/bin/v2ray -test -config /usr/local/etc/v2ray/config.json
[root@iZ23wv7v5ggZ ~]# yum -y install privoxy
Loaded plugins: fastestmirror
Determining fastest mirrors
base                                                     | 3.6 kB     00:00
epel                                                     | 4.7 kB     00:00
extras                                                   | 2.9 kB     00:00
updates                                                  | 2.9 kB     00:00
(1/7): base/7/x86_64/group_gz                              | 153 kB   00:00
(2/7): epel/x86_64/group_gz                                |  96 kB   00:00
(3/7): epel/x86_64/updateinfo                              | 1.0 MB   00:00
(4/7): extras/7/x86_64/primary_db                          | 242 kB   00:00
(5/7): base/7/x86_64/primary_db                            | 6.1 MB   00:00
(6/7): epel/x86_64/primary_db                              | 6.9 MB   00:00
(7/7): updates/7/x86_64/primary_db                         | 8.8 MB   00:00
Resolving Dependencies
--> Running transaction check
---> Package privoxy.x86_64 0:3.0.32-1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package           Arch             Version                Repository      Size
================================================================================
Installing:
 privoxy           x86_64           3.0.32-1.el7           epel           998 k

Transaction Summary
================================================================================
Install  1 Package

Total download size: 998 k
Installed size: 3.1 M
Downloading packages:
privoxy-3.0.32-1.el7.x86_64.rpm                            | 998 kB   00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : privoxy-3.0.32-1.el7.x86_64                                  1/1
  Verifying  : privoxy-3.0.32-1.el7.x86_64                                  1/1

Installed:
  privoxy.x86_64 0:3.0.32-1.el7

Complete!

[root@iZ23wv7v5ggZ ~]# systemctl enable privoxy
Created symlink from /etc/systemd/system/multi-user.target.wants/privoxy.service to /usr/lib/systemd/system/privoxy.service.
[root@iZ23wv7v5ggZ ~]# systemctl start privoxy
[root@iZ23wv7v5ggZ ~]# systemctl status privoxy
● privoxy.service - Privoxy Web Proxy With Advanced Filtering Capabilities
   Loaded: loaded (/usr/lib/systemd/system/privoxy.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2021-06-24 11:08:07 CST; 5s ago
  Process: 6845 ExecStart=/usr/sbin/privoxy --pidfile /run/privoxy.pid --user privoxy /etc/privoxy/config (code=exited, status=0/SUCCESS)
 Main PID: 6846 (privoxy)
   CGroup: /system.slice/privoxy.service
           └─6846 /usr/sbin/privoxy --pidfile /run/privoxy.pid --user privoxy...

Jun 24 11:08:06 iZ23wv7v5ggZ systemd[1]: Starting Privoxy Web Proxy With Adv....
Jun 24 11:08:07 iZ23wv7v5ggZ systemd[1]: Started Privoxy Web Proxy With Adva....
Hint: Some lines were ellipsized, use -l to show in full.
[root@iZ23wv7v5ggZ ~]# yum install w3m -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package w3m.x86_64 0:0.5.3-50.git20210102.el7 will be installed
--> Processing Dependency: libcrypto.so.1.1(OPENSSL_1_1_0)(64bit) for package: w3m-0.5.3-50.git20210102.el7.x86_64
--> Processing Dependency: libssl.so.1.1(OPENSSL_1_1_0)(64bit) for package: w3m-0.5.3-50.git20210102.el7.x86_64
--> Processing Dependency: perl(NKF) for package: w3m-0.5.3-50.git20210102.el7.x86_64
--> Processing Dependency: libcrypto.so.1.1()(64bit) for package: w3m-0.5.3-50.git20210102.el7.x86_64
--> Processing Dependency: libgc.so.1()(64bit) for package: w3m-0.5.3-50.git20210102.el7.x86_64
--> Processing Dependency: libssl.so.1.1()(64bit) for package: w3m-0.5.3-50.git20210102.el7.x86_64
--> Running transaction check
---> Package gc.x86_64 0:7.2d-7.el7 will be installed
---> Package openssl11-libs.x86_64 1:1.1.1g-3.el7 will be installed
---> Package perl-NKF.x86_64 1:2.1.3-5.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package             Arch        Version                        Repository
                                                                           Size
================================================================================
Installing:
 w3m                 x86_64      0.5.3-50.git20210102.el7       epel      980 k
Installing for dependencies:
 gc                  x86_64      7.2d-7.el7                     base      158 k
 openssl11-libs      x86_64      1:1.1.1g-3.el7                 epel      1.5 M
 perl-NKF            x86_64      1:2.1.3-5.el7                  epel      131 k

Transaction Summary
================================================================================
Install  1 Package (+3 Dependent packages)

Total download size: 2.7 M
Installed size: 6.5 M
Downloading packages:
(1/4): gc-7.2d-7.el7.x86_64.rpm                            | 158 kB   00:00
(2/4): perl-NKF-2.1.3-5.el7.x86_64.rpm                     | 131 kB   00:00
(3/4): openssl11-libs-1.1.1g-3.el7.x86_64.rpm              | 1.5 MB   00:00
(4/4): w3m-0.5.3-50.git20210102.el7.x86_64.rpm             | 980 kB   00:00
--------------------------------------------------------------------------------
Total                                              5.0 MB/s | 2.7 MB  00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 1:openssl11-libs-1.1.1g-3.el7.x86_64                         1/4
  Installing : gc-7.2d-7.el7.x86_64                                         2/4
  Installing : 1:perl-NKF-2.1.3-5.el7.x86_64                                3/4
  Installing : w3m-0.5.3-50.git20210102.el7.x86_64                          4/4
  Verifying  : 1:perl-NKF-2.1.3-5.el7.x86_64                                1/4
  Verifying  : gc-7.2d-7.el7.x86_64                                         2/4
  Verifying  : w3m-0.5.3-50.git20210102.el7.x86_64                          3/4
  Verifying  : 1:openssl11-libs-1.1.1g-3.el7.x86_64                         4/4

Installed:
  w3m.x86_64 0:0.5.3-50.git20210102.el7

Dependency Installed:
  gc.x86_64 0:7.2d-7.el7              openssl11-libs.x86_64 1:1.1.1g-3.el7
  perl-NKF.x86_64 1:2.1.3-5.el7

Complete!
[root@iZ23wv7v5ggZ ~]# vi /etc/privoxy/config
[root@iZ23wv7v5ggZ ~]#


Plaintext
listen-address 127.0.0.1:8118
forward-socks5t / 127.0.0.1:1081 .

15. Set up the HTTP/HTTPS proxy by modifying the configuration file /etc/profile. 172.16.6.176 is the server’s internal IP address, indicating that no proxy is used. See Figure 10.

Set up the HTTP/HTTPS proxy by modifying the configuration file /etc/profile. 172.16.6.176 is the server's internal IP address, indicating that no proxy is used
Figure 10
Plaintext
[root@iZ23wv7v5ggZ ~]# vi /etc/profile
[root@iZ23wv7v5ggZ ~]# systemctl stop privoxy
[root@iZ23wv7v5ggZ ~]# systemctl start privoxy
[root@iZ23wv7v5ggZ ~]# systemctl status privoxy
● privoxy.service - Privoxy Web Proxy With Advanced Filtering Capabilities
   Loaded: loaded (/usr/lib/systemd/system/privoxy.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2021-06-25 19:17:34 CST; 10s ago
  Process: 10823 ExecStart=/usr/sbin/privoxy --pidfile /run/privoxy.pid --user privoxy /etc/privoxy/config (code=exited, status=0/SUCCESS)
 Main PID: 10824 (privoxy)
   CGroup: /system.slice/privoxy.service
           └─10824 /usr/sbin/privoxy --pidfile /run/privoxy.pid --user privoxy /etc/privoxy/config

Jun 25 19:17:33 iZ23wv7v5ggZ systemd[1]: Starting Privoxy Web Proxy With Advanced Filtering Capabilities...
Jun 25 19:17:34 iZ23wv7v5ggZ systemd[1]: Started Privoxy Web Proxy With Advanced Filtering Capabilities.
[root@iZ23wv7v5ggZ ~]# 

Plaintext
export http_proxy=http://127.0.0.1:8118
export https_proxy=http://127.0.0.1:8118
export ftp_proxy=http://127.0.0.1:8118
export no_proxy="172.16.6.176"

16. Test the Alibaba Cloud server making curl HTTP requests to http://httpbin.org/ip, https://www.google.com, and https://www.youtube.com. The connection is successful. See Figure 11.

Test the Alibaba Cloud server making curl HTTP requests to http://httpbin.org/ip, https://www.google.com, and https://www.youtube.com. The connection is successful
Figure 11
Plaintext
[root@iZ23wv7v5ggZ ~]# curl -v http://httpbin.org/ip
* About to connect() to proxy 127.0.0.1 port 8118 (#0)
*   Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 8118 (#0)
> GET http://httpbin.org/ip HTTP/1.1
> User-Agent: curl/7.29.0
> Host: httpbin.org
> Accept: */*
> Proxy-Connection: Keep-Alive
> 
< HTTP/1.1 200 OK
< Date: Tue, 29 Jun 2021 11:28:55 GMT
< Content-Type: application/json
< Content-Length: 31
< Connection: keep-alive
< Server: gunicorn/19.9.0
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Credentials: true
< Proxy-Connection: keep-alive
< 
{
  "origin": "14.192.49.13"
}
* Connection #0 to host 127.0.0.1 left intact
[root@iZ23wv7v5ggZ ~]# curl -v http://www.google.com
* About to connect() to proxy 127.0.0.1 port 8118 (#0)
*   Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 8118 (#0)
> GET http://www.google.com/ HTTP/1.1
> User-Agent: curl/7.29.0
> Host: www.google.com
> Accept: */*
> Proxy-Connection: Keep-Alive
> 
< HTTP/1.1 302 Found
< Location: http://www.google.com.hk/url?sa=p&hl=zh-CN&pref=hkredirect&pval=yes&q=http://www.google.com.hk/&ust=1624966178742441&usg=AOvVaw2QC6Lusz__XY4CV4128vDo
< Cache-Control: private
< Content-Type: text/html; charset=UTF-8
< P3P: CP="This is not a P3P policy! See g.co/p3phelp for more info."
< Date: Tue, 29 Jun 2021 11:29:08 GMT
< Server: gws
< Content-Length: 370
< X-XSS-Protection: 0
< X-Frame-Options: SAMEORIGIN
< Set-Cookie: 1P_JAR=2021-06-29-11; expires=Thu, 29-Jul-2021 11:29:08 GMT; path=/; domain=.google.com; Secure
< Set-Cookie: NID=218=mAQ-WwaoohthEWglgFX6uc1oS1THml90khjAACvGj_9OGJ73I3SvN6kwGB4ahRX3uZh5Sw0__Q-y5ahjTAvJtItGntahKmj_d4ESUipCEyIjCRsskk88MU_sF6xOPwhvpqQdY3Zs5ZdscNbvbvB5Z0n0iVnRtGayv2Is44Z8phc; expires=Wed, 29-Dec-2021 11:29:08 GMT; path=/; domain=.google.com; HttpOnly
< Proxy-Connection: keep-alive
< 

302 Moved
302 Moved
The document has moved
here.

* Connection #0 to host 127.0.0.1 left intact
[root@iZ23wv7v5ggZ ~]# curl -v https://www.google.com
* About to connect() to proxy 127.0.0.1 port 8118 (#0)
*   Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 8118 (#0)
* Establish HTTP proxy tunnel to www.google.com:443
> CONNECT www.google.com:443 HTTP/1.1
> Host: www.google.com:443
> User-Agent: curl/7.29.0
> Proxy-Connection: Keep-Alive
> 
< HTTP/1.1 200 Connection established
< 
* Proxy replied OK to CONNECT request
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* SSL connection using TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
* Server certificate:
*       subject: CN=www.google.com,O=Google LLC,L=Mountain View,ST=California,C=US
*       start date: May 31 03:52:12 2021 GMT
*       expire date: Aug 23 03:52:11 2021 GMT
*       common name: www.google.com
*       issuer: CN=GTS CA 1O1,O=Google Trust Services,C=US
> GET / HTTP/1.1
> User-Agent: curl/7.29.0
> Host: www.google.com
> Accept: */*
> 
< HTTP/1.1 302 Found
< Location: https://www.google.com.hk/url?sa=p&hl=zh-CN&pref=hkredirect&pval=yes&q=https://www.google.com.hk/&ust=1624966197905473&usg=AOvVaw3rpxJ3M42WvO-874oCUUAA
< Cache-Control: private
< Content-Type: text/html; charset=UTF-8
< P3P: CP="This is not a P3P policy! See g.co/p3phelp for more info."
< Date: Tue, 29 Jun 2021 11:29:27 GMT
< Server: gws
< Content-Length: 372
< X-XSS-Protection: 0
< X-Frame-Options: SAMEORIGIN
< Set-Cookie: 1P_JAR=2021-06-29-11; expires=Thu, 29-Jul-2021 11:29:27 GMT; path=/; domain=.google.com; Secure
< Set-Cookie: NID=218=Oer550Xi5XY2PWWVqYODOuO0eo3bDFJv7wRpooU1FMnNvfWZSI9azb4-oPY_CIbBjn1Wyt4ycJYne9IHTdySDugiDbXhZeEnWSt66bpphBWLPcNyQyEqIS1ltdCHGJw_C8XV3LSlF2NSUbtI825BQGha3baM6qJVvQI2x2Pj-XU; expires=Wed, 29-Dec-2021 11:29:27 GMT; path=/; domain=.google.com; HttpOnly
< Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
< 

302 Moved
302 Moved
The document has moved
here.

* Connection #0 to host 127.0.0.1 left intact
[root@iZ23wv7v5ggZ ~]# curl -v https://sitekit.withgoogle.com
* About to connect() to proxy 127.0.0.1 port 8118 (#0)
*   Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 8118 (#0)
* Establish HTTP proxy tunnel to sitekit.withgoogle.com:443
> CONNECT sitekit.withgoogle.com:443 HTTP/1.1
> Host: sitekit.withgoogle.com:443
> User-Agent: curl/7.29.0
> Proxy-Connection: Keep-Alive
> 
< HTTP/1.1 200 Connection established
< 
* Proxy replied OK to CONNECT request
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* SSL connection using TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
* Server certificate:
*       subject: CN=*.appspot.com,O=Google LLC,L=Mountain View,ST=California,C=US
*       start date: Jun 07 01:07:29 2021 GMT
*       expire date: Aug 30 01:07:28 2021 GMT
*       common name: *.appspot.com
*       issuer: CN=GTS CA 1O1,O=Google Trust Services,C=US
> GET / HTTP/1.1
> User-Agent: curl/7.29.0
> Host: sitekit.withgoogle.com
> Accept: */*
> 
< HTTP/1.1 200 OK
< Content-Type: text/html; charset=utf-8
< Vary: Accept-Encoding
< X-Cloud-Trace-Context: 803be8061a081faa119115967f932ca2
< Date: Tue, 29 Jun 2021 11:29:47 GMT
< Server: Google Frontend
< Content-Length: 89089
< Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
< 

^C
[root@iZ23wv7v5ggZ ~]# curl -v https://www.youtube.com
* About to connect() to proxy 127.0.0.1 port 8118 (#0)
*   Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 8118 (#0)
* Establish HTTP proxy tunnel to www.youtube.com:443
> CONNECT www.youtube.com:443 HTTP/1.1
> Host: www.youtube.com:443
> User-Agent: curl/7.29.0
> Proxy-Connection: Keep-Alive
> 
< HTTP/1.1 200 Connection established
< 
* Proxy replied OK to CONNECT request
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* SSL connection using TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
* Server certificate:
*       subject: CN=*.google.com,O=Google LLC,L=Mountain View,ST=California,C=US
*       start date: May 31 01:35:44 2021 GMT
*       expire date: Aug 23 01:35:43 2021 GMT
*       common name: *.google.com
*       issuer: CN=GTS CA 1O1,O=Google Trust Services,C=US
> GET / HTTP/1.1
> User-Agent: curl/7.29.0
> Host: www.youtube.com
> Accept: */*
> 
< HTTP/1.1 200 OK
< Content-Type: text/html; charset=utf-8
< X-Content-Type-Options: nosniff
< Cache-Control: no-cache, no-store, max-age=0, must-revalidate
< Pragma: no-cache
< Expires: Mon, 01 Jan 1990 00:00:00 GMT
< Date: Tue, 29 Jun 2021 11:30:03 GMT
< X-Frame-Options: SAMEORIGIN
< Strict-Transport-Security: max-age=31536000
< permissions-policy: ch-ua-full-version=*, ch-ua-platform=*, ch-ua-platform-version=*, ch-ua-arch=*, ch-ua-model=*
< P3P: CP="This is not a P3P policy! See http://support.google.com/accounts/answer/151657?hl=en for more info."
< Server: ESF
< X-XSS-Protection: 0
< Set-Cookie: GPS=1; Domain=.youtube.com; Expires=Tue, 29-Jun-2021 12:00:03 GMT; Path=/; Secure; HttpOnly
< Set-Cookie: YSC=qYlVjgY4Muk; Domain=.youtube.com; Path=/; Secure; HttpOnly; SameSite=none
< Set-Cookie: VISITOR_INFO1_LIVE=kVRgqbeY_lI; Domain=.youtube.com; Expires=Sun, 26-Dec-2021 11:30:03 GMT; Path=/; Secure; HttpOnly; SameSite=none
< Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
< Accept-Ranges: none
< Vary: Accept-Encoding
< Transfer-Encoding: chunked
< 
^C
[root@iZ23wv7v5ggZ ~]# 

关于作者 · 持续学习与技术实践

我是一名拥有 15 年以上开发经验的技术从业者,自 2013 年起持续运营个人技术博客,记录工作与个人项目中遇到的真实问题,以及解决问题过程中的探索、实践和思考。

除了技术写作,我也在持续开发和维护自己的独立项目,探索新技术和新工具在实际场景中的应用。我始终相信,没有不值得去解决的问题,也没有不值得去学习的技术。

如果这篇文章对你有所帮助,欢迎浏览博客中的其他文章,也欢迎交流技术经验与想法。

关于我  ·  GitHub  ·  邮件联系