windows 使用 nginx 反向代理

windows 使用 nginx  反向代理   

至于什么是反向代理   可以  自行百度,

上编文章已经是安装成功nginx了,现在就可以玩nginx  ,到低有多好玩,看看你就知道

#user  nobody;
worker_processes  2;  

#错误日志存放路径  
#error_log  logs/error.log;  
#error_log  logs/error.log  notice;  
error_log  logs/error.log  info; 

#指定pid存放文件  
pid        logs/nginx.pid; 


events {  
    #使用网络IO模型linux建议epoll,FreeBSD建议采用kqueue,window下不指定。  
    #use epoll;  
      
    #允许最大连接数  
    worker_connections  2048;  
} 


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  off;  
    access_log  logs/access.log;  
  
    client_header_timeout  3m;  
    client_body_timeout    3m;  
    send_timeout           3m;  
   
    client_header_buffer_size    1k;  
    large_client_header_buffers  4 4k;  
  
    sendfile        on;  
    tcp_nopush      on;  
    tcp_nodelay     on;  
  
    #keepalive_timeout  75 20;  
  
    include    gzip.conf;  
   
  #代理web服务
    server {  
            listen       8081;  
            server_name  localhost;     
			
			location = /50x.html {
				root   html;
			}
            
			location / {
            root   html;
            index  index.html index.htm index.jsp;
            proxy_pass http://127.0.0.1:8080/;
         }
              
   } 
}  
其中  listen   8081  这是  开启  反向代理开放 端口    如果 被占用了  就换一个

proxy_pass http://127.0.0.1:8080/;   这是  进行  反向代理   的   地址


比如   ,你本机  运行  tomcat   http://127.0.0.1:8080/app_web     是项目访问路径

   配置好反向代理后   开启  nginx       即可   访问   http://127.0.0.1:8081/app_web       

两个地址都可以     使用

猜你喜欢

转载自blog.csdn.net/zsm136767349700/article/details/53743968