Using Nginx to do proxy server Internet access

Source: Internet
Author: User
Tags nginx server

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:
  1. Worker_processes 1;
  2. Master_process off;
  3. Daemon off;
  4. #pid/var/run/nginx.pid;
  5. Events {
  6. Worker_connections 768;
  7. # multi_accept on;
  8. }
  9. HTTP {
  10. Include Mime.types;
  11. Default_type Application/octet-stream;
  12. Log_format Main ' $remote _addr-$remote _user [$time _local] "$request" '
  13. ' $status $body _bytes_sent ' $http _referer '
  14. ' "$http _user_agent" "$http _x_forwarded_for";
  15. Access_log/var/log/nginx/access.log;
  16. Error_log/var/log/nginx/error.log;
  17. Sendfile on;
  18. server {
  19. Resolver 10.57.220.2;
  20. Listen 82;
  21. Access_log Logs/host.access.log Main;
  22. Location/{
  23. Proxy_pass http://$http _host$request_uri;
  24. }
  25. }
  26. }
  27. 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

Related Article

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.