Use nginx as a proxy server to access the Internet

 

 

jadedeMacBook-Air.local

Current status: only one machine can access the Internet (web), other machines cannot
Method: If you can access the Internet, you can do a proxy web server transfer, and other machines can connect to it. using nginx

Nginx is configured as follows:

server{
        resolve xxxx;
        listen 82;
        location / {
                proxy_pass http://$http_host$request_uri;
        }
}

Notes:
1. Cannot have hostname
2. There must be a resolver, that is, dns, that is, the above xxxx, you can replace it with your DNS server ip
3. $http_host and $request_uri are nginx system variables, don't think about replacing them, it's OK to keep them as they are.

view dns method
cat /etc/resolv.conf

proxy use

Perform one of the following operations on the machine that needs to access the external network:
1. export http_proxy=http://yourproxyaddress:proxyport
2. gedit ~/.bashrc  
    export http_proxy=http://yourproxyaddress:proxyport
Yourproxyaddress is the ip of your Nginx server, proxyport is 82 in the above configuration, you can modify it according to your needs.

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326407893&siteId=291194637