1 Nginx introduction Nginx is similar to Apache & amp; 20284;. in the past, the lab network was unrestricted, while many foreign websites in the dormitory could not be opened, and both the dormitory and lab were on the campus network, this allows you to browse the web page in the dormitory through the lab network. nginx introduction Nginx is similar to Apache. in the past, the lab network was unrestricted, while many foreign websites in the dormitory could not be opened, and both the dormitory and lab were on the campus network, this allows you to browse the web page through the lab network in the dormitory through the proxy. in this way, I forget whether it is a forward proxy or a reverse proxy ????
2. the following is the modified configuration file.
#/Etc/nginx. conf
######################################## ################################# This is the main Nginx configuration file. # More information about the configuration options is available on # * the English wiki-http://wiki.nginx.org/Main# * the Russian documentation-http://sysoev.ru/nginx /######################################################################## # Modules # Main Module-directives that cover basic functionality # http://wiki.nginx.org/NginxHttpMainModule ---------------------------------------------------------------------- User nginx; worker_processes 1; Error_log/var/log/nginx/error. log; # error_log/var/log/nginx/error. log notice; # error_log/var/log/nginx/error. log info; Pid/var/run/nginx. pid;
# Sources # Events Module # http://wiki.nginx.org/NginxHttpEventsModule ---------------------------------------------------------------------- Events {worker_connections 1024 ;}
# Certificate # HTTP Core Module # http://wiki.nginx.org/NginxHttpCoreModule ##---------------------------------------------------------------------- Http {include/etc/nginx/mime. types; default_type application/octet-stream; Log_format main '$ remote_addr-$ remote_user [$ time_local] "$ request" ''$ status $ response" $ http_referer "'' "$ http_user_agent" "$ http_x_forwarded_for "'; Access_log/var/log/nginx/access. log main; Sendfile on; # tcp_nopush on; # Keepalive_timeout 0; keepalive_timeout 65; # Gzip on; # The default server # server {resolver 222.201.130.30; listen 82; server_name _; # Charset KOI8-R; # Access_log logs/host. access. log main; # Location/{proxy_pass http: // $ http_host $ request_uri ;} Error_page 404/404 .html; location =/404.html {root/usr/share/nginx/html ;} # Redirect server error pages to the static page/50x.html # error_page 500 502 503 504/50 x.html; location =/50x.html {root/usr/share/nginx/html ;} # Proxy the PHP scripts to Apache listening on 127.0.0.1: 80 # location ~ \. Php $ {# proxy_pass http: // 127.0.0.1 ;#} # Pass the PHP scripts to FastCGI server listening on 127.0.0.1: 9000 # location ~ \. Php $ {# root html; # fastcgi_pass 127.0.0.1: 9000; # fastcgi_index index. php; # fastcgi_param SCRIPT_FILENAME/scripts $ fastcgi_script_name; # include fastcgi_params ;#} # Deny access to. htaccess files, if Apache's document root # concurs with nginx's one # location ~ /\. Ht {# deny all ;#}} # Load config files from the/etc/nginx/conf. d directory include/etc/nginx/conf. d/*. conf; } |
3. the current status of the main changes: only one machine can access the Internet (web), and other machines cannot
Method: a proxy web server can be used for Internet access, and other machines can connect to it. Nginx
The Nginx configuration is as follows:
Server {
Resolver x. x;
Listen 82;
Location /{
Proxy_pass http: // $ http_host $ request_uri ;}}
Note: 1. there cannot be hostname2. there must be a resolver, that is, dns, that is, the above x. x. x. x. replace it with your DNS server ip address. $ http_host and $ request_uri are nginx system variables. do not replace them. if they are the same, they are OK.
View dns methods cat/etc/resolv. conf
4. the proxy is used in linux. I remember using a plug-in the chrome browser at that time. just fill in the proxy server IP address and port.
1. export http_proxy = http: // yourproxyaddress: proxyport2. gedit ~ /. Bashrc export http_proxy = http: // yourproxyaddress: proxyportyourproxyaddress is the ip address of your Nginx server. proxyport is the 82 configured above and can be modified as needed.
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;
- }
- }
- }