Configure the nginx HTTP proxy server, which has the same function as [squid] and is applicableForward proxy HTTP website.
1. nginx forward proxy configuration file:
Server {resolver 8.8.8.8; resolver_timeout 5S; Listen 0.0.0.0: 8080; access_log/home/reistlin/logs/proxy. access. log; error_log/home/reistlin/logs/proxy. error. log; Location/{proxy_pass $ scheme: // $ host $ request_uri; proxy_set_header host $ http_host; proxy_buffers 256 4 K; Limit 0; proxy_connect_timeout 30; proxy_cache_valid 200 10 m; proxy_cache_valid 301 1 h; proxy_cache_valid any 1 m ;}}
2. nginx forward proxy configuration instructions:
1. Configure the DNS resolution IP address, such as Google public DNS, And the timeout time (5 seconds ).
Resolver 8.8.8.8; resolver_timeout 5S;
2. Configure forward proxy parameters, which are composed of nginx variables. The proxy_set_header configuration is used to solve the nginx 503 error after the URL contains "." (DOT.
Proxy_pass $ scheme: // $ host $ request_uri; proxy_set_header host $ http_host;
3. Configure the cache size, disable disk cache read/write, and reduce I/O, as well as the proxy connection timeout.
Proxy_buffers 256 4 K; proxy_max_temp_file_size 0; proxy_connect_timeout 30;
4. Configure the HTTP status Cache Time of the proxy server.
Proxy_cache_valid 200 302 10 m; proxy_cache_valid 301 1 h; proxy_cache_valid any 1 m;
3. Proxy HTTPS websites not supported
Because nginx does not support connectYou cannot directly proxy HTTPS websites (online banking, Gmail ).
If you access an HTTPS website such as a https://www.google.com, The nginx access. log is as follows:
"Connect www.google.com: 443 HTTP/1.1" 400