Linux Setup Http/https Proxy and method of ignoring proxy

Source: Internet
Author: User
Tags fpm

One, the scene:

Some Linux servers are in the intranet, and there is no public network IP, so you want to communicate with the external network can only be HTTP/HTTPS through the way of NAT or proxy. NAT server has the restriction of network segment, and HTTP/HTTPS proxy agent is not, it is convenient to use. However, two problems were encountered when using HTTP/HTTPS proxy:

1, the local access to a domain without domain name resolution but bind the Hosts file name, resulting in Access failure

2,PHP-FPM run in the PHP code access to the external network has a domain name resolution interface, access failure


Linux System Setup Http/https Proxy method, add the following environment variable in/ETC/BASHRC or/etc/profile:

Export Http_proxy=http://1.1.1.1:8082export https_proxy=http://1.1.1.1:8082



Second, the cause of the problem

1, it should be because the priority level of the environment variable is higher than the/etc/hosts file, which causes the local to access a domain name that does not have a domain name resolution but binds the hosts file while still walking Http/https proxy, and the proxy server does not access the domain name to be specified resulting in Access failure.

2,PHP-FPM default is not loaded into the system HTTP/HTTPS proxy environment variable settings, you need to modify the configuration of PHP-FPM to solve the problem.



Third, problem solving

1, for those who do not have domain name resolution by binding the hosts file to access the domain name, do not let it go Http/https proxy

Add the following environment variables in/ETC/BASHRC or/etc/profile:

Export no_proxy= ' a.test.com,127.0.0.1,2.2.2.2 '

2, add the following configuration of php-fpm about Env, and then restart PHP-FPM:

Env[http_proxy] = "http_proxy=http://1.1.1.1:8082" env[https_proxy] = "https_proxy=http://1.1.1.1:8082" Env[no_proxy ] = "a.test.com,127.0.0.1,2.2.2.2"



Four, expand

1, used Http/https proxy software:

Nginx

Tinyproxy (easy to use, support HTTP/HTTPS protocol)











Linux Setup Http/https Proxy and method of ignoring proxy

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.