Using Nginx to do proxy server Internet access
Current status: Only 1 machines can access the Internet (web), other machines cannot
Methods: The Internet can be used as a proxy Web server relay, other machines can connect it. Using Nginx
The Nginx configuration is as follows:
server{
Resolver x.x.x.x;
Listen 82;
Location/{
Proxy_pass http://$http _host$request_uri;
}
}
Note Item:
1. Cannot have hostname
2. Must have resolver, that is, DNS, that is, the above x.x.x.x, replaced by your DNS server IP can be
3. $http _host and $request_uri are nginx system variables, do not want to replace them, remain as is OK.
View DNS Methods
Cat/etc/resolv.conf
Agent use
Do one of the following on a machine that requires access to the extranet:
1. Export Http_proxy=http://yourproxyaddress:proxyport
2. Gedit ~/.BASHRC
Export Http_proxy=http://yourproxyaddress:proxyport
Yourproxyaddress is your nginx server IP, ProxyPort is the above configuration of 82, can be modified according to their own needs.
Example:
- Worker_processes 1;
- Master_process off;
- Daemon off;
- #pid/var/run/nginx.pid;
- Events {
- Worker_connections 768;
- # multi_accept on;
- }
- HTTP {
- Include Mime.types;
- Default_type Application/octet-stream;
- Log_format Main ' $remote _addr-$remote _user [$time _local] "$request" '
- ' $status $body _bytes_sent ' $http _referer '
- ' "$http _user_agent" "$http _x_forwarded_for";
- Access_log/var/log/nginx/access.log;
- Error_log/var/log/nginx/error.log;
- Sendfile on;
- server {
- Resolver 10.57.220.2;
- Listen 82;
- Access_log Logs/host.access.log Main;
- Location/{
- Proxy_pass http://$http _host$request_uri;
- }
- }
- }
Part 5th: Test and start Nginx
Ulimit-shn 51200
/usr/local/webserver/nginx/sbin/nginx-t
/usr/local/webserver/nginx/sbin/nginx
Part 6th: Nginx Log Cutting script
Using Nginx to do proxy server Internet access