仙居做网站,有趣的网站知乎,哪些做直播卖食品的网站,网站logo是什么什么是反向代理#xff1f;反向代理#xff08;Reverse Proxy#xff09;方式是指以代理服务器来接受internet上的连接请求#xff0c;然后将请求转发给内部网络上的服务器#xff0c;并将从服务器上得到的结果返回给internet上请求连接的客户端#xff0c;此时代理服务器…什么是反向代理反向代理Reverse Proxy方式是指以代理服务器来接受internet上的连接请求然后将请求转发给内部网络上的服务器并将从服务器上得到的结果返回给internet上请求连接的客户端此时代理服务器对外就表现为一个反向代理服务器。怎么配置nginx实现以上目标环境参数nginx目录D:/nginx-1.14.2/应用程序目录D:nginx-1.14.2htmlInternet入口IP地址和端口1.2.3.4:80应用程序IP地址和端口127.0.0.1:80882.nginx.conf 配置文件如下注conf / nginx.conf 是 nginx 的默认配置文件。你也可以使用 nginx -c 指定你的配置文件。#运行用户
#user nobody;
#启动进程,通常设置成和cpu的数量相等
worker_processes 1;
#全局错误日志
error_log D:/nginx-1.14.2/logs/error.log;
error_log D:/nginx-1.14.2/logs/error.log notice;
error_log D:/nginx-1.14.2/logs/error.log info;
#PID文件记录当前启动的nginx的进程ID
pid D:/nginx-1.14.2/logs/nginx.pid;
#工作模式及连接数上限
events {worker_connections 1024; #单个后台worker process进程的最大并发链接数
}#设定http服务器利用它的反向代理功能提供负载均衡支持
http {#设定mime类型(邮件支持类型),类型由mime.types文件定义include D:/nginx-1.14.2/conf/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 D:/nginx-1.14.2/logs/access.log main;rewrite_log on;#sendfile 指令指定 nginx 是否调用 sendfile 函数zero copy 方式来输出文件对于普通应用#必须设为 on,如果用来进行下载等应用磁盘IO重负载应用可设置为 off以平衡磁盘与网络I/O处理速度降低系统的uptime.sendfile on;#tcp_nopush on;#连接超时时间keepalive_timeout 120;tcp_nodelay on;#gzip压缩开关#gzip on;#设定实际的服务器列表 upstream zp_server1{server 127.0.0.1:8088;}#HTTP服务器server {#监听80端口80端口是知名端口号用于HTTP协议listen 80;#定义使用www.xx.com访问server_name 1.2.3.4;#首页index index.html#指向webapp的目录root D:nginx-1.14.2html;#编码格式charset utf-8;#代理配置参数proxy_connect_timeout 180;proxy_send_timeout 180;proxy_read_timeout 180;proxy_set_header Host $host;proxy_set_header X-Forwarder-For $remote_addr;#反向代理的路径和upstream绑定location 后面设置映射的路径location / {proxy_pass http://zp_server1;} #设定查看Nginx状态的地址location /NginxStatus {stub_status on;access_log on;auth_basic NginxStatus;auth_basic_user_file conf/htpasswd;}#禁止访问 .htxxx 文件location ~ /.ht {deny all;}#错误处理页面可选择性配置#error_page 404 /404.html;# redirect server error pages to the static page /50x.html#error_page 500 502 503 504 /50x.html;location /50x.html {root html;}}
}3.启动应用程序4.启动nginx服务D:nginx-1.14.2nginx.exe -c conf/nginx.conf5.在浏览器中输入1.2.3.4,就可以访问了。