当前位置: 首页 > news >正文

网站建设图网站推广的几种方法

网站建设图,网站推广的几种方法,2015做微网站多少钱,青之峰网站建设哪家好nginx 进阶篇 文章目录nginx 进阶篇一、Nginx Proxy 服务器1、代理原理2、proxy代理3、proxy缓存一、Nginx Proxy 服务器 1、代理原理 正向代理 内网客户机通过代理访问互联网,通常要设置代理服务器地址和端口。 反向代理 外网用户通过代理访问内网服务器&…

nginx 进阶篇


文章目录

  • nginx 进阶篇
  • 一、Nginx Proxy 服务器
    • 1、代理原理
    • 2、proxy代理
    • 3、proxy缓存


在这里插入图片描述


一、Nginx Proxy 服务器

1、代理原理

  • 正向代理

内网客户机通过代理访问互联网,通常要设置代理服务器地址和端口。
在这里插入图片描述

  • 反向代理
    外网用户通过代理访问内网服务器,内网服务器无感知。
    在这里插入图片描述

在这里插入图片描述

  • 正向代理与反向代理的区别是什么?

2、proxy代理

  • 模块:ngx_http_proxy_module

  • 语法:

代理
Syntax: proxy_pass_ URL; 代理的后端服务器URL
Default: _
Context: location,if in location,limit_except

缓冲区
Syntax: proxy_buffering on | off;
Default: proxy_buffering on | off; # 缓冲开关
Context: http,server,location
proxy_buffering 开启的情况下,nginx会把后端返回的内容先放到缓冲区当中,然后再返回给客户端(边收边传,不是全部接收完在传给客户端读)

Syntax: proxy_buffersnumber size ;
Default: proxy_buffer_size 4k|8k; # 缓冲区数量
Context: http,server,location

Syntax: proxy_buffer_size size ;
Default: proxy_buffers 8 4k|8k; # 缓冲区大小
Context: http,server,location

Syntax: proxy_busy_buffers_size size ;
Default: proxy_busy_buffers_size 8k|16k; # 忙碌缓冲区的大小,控制同时传递给客户端的buffer数量
Context: http,server,location

头信息
Syntax: proxy_set_header field value ;
Default: proxy_set_header Host $proxy_host ; # 设置真实客户端地址
proxy_set_header Connection close;
Context: http,server,location

超时

Syntax: proxy_connect_timeout time ;
Default: proxy_connect_timeout 60s; # 连接超
Context: http,server,location

Syntax: proxy_read_timeout time ;
Default: proxy_connect_timeout 60s;
Context: http,server,location

Syntax: proxy_send_timeout time ; # nginx进程向fastcgi进程发送request的整个过程的超时时间
Default: proxy_send_timeout 60s;
Context: http,server,location

  • 启用代理
    环境:两台nginx服务器
IPservername
192.168.200.184nginx1
192.168.200.186nginx2

两台服务器分别安装好nginx

1.nginx1 启动网站(内容)

yum install -y nginx
systemctl start nginx
[root@nginx1 html]# cat /usr/share/nginx/html/index.html 
Hello World!
<img src="test.jpg" width=400 border=3 />
[root@nginx1 html]# 

在这里插入图片描述

2.nginx2 启动代理程序

yum install -y nginx
systemctl start nginx
[root@nginx2 html]# vim /etc/nginx/conf.d/default.conflocation / {proxy_pass http://192.168.200.184:80;proxy_redirect default;proxy_set_header Host $http_host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_connect_timeout 60;proxy_send_timeout 60;proxy_read_timeout 60;proxy_buffering on;proxy_buffer_size  32k;proxy_buffers  4   128k;proxy_busy_buffers_size   256k;proxy_max_temp_file_size   256k;# 启动代理程序可以注释掉下面的内容#expires 24h;#root   /usr/share/nginx/html;#index  index.html index.htm;# root /app;# random_index on;}
[root@nginx2 html]# systemctl restart nginx

在这里插入图片描述

3.结果:开启代理之后访问192.168.200.184 和192.168.200.186 的内容一样的
在这里插入图片描述
在这里插入图片描述
4.观察nginx1服务器的日志

[root@nginx1 html]# cat /var/log/nginx/access.log
192.168.200.186 - - [09/Feb/2023:00:18:24 +0800] "GET /test.jpg HTTP/1.0" 200 350627 "http://192.168.200.186/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36" "192.168.200.1"

访问成功,记录了客户机的IP和代理服务器的IP

3、proxy缓存

  • 缓存类型
    网页缓存(公网)CDN
    数据库缓存 memcache redis
    网页缓存 nginx-proxy
    客户端缓存 浏览器缓存

  • 模块:ngx_http_proxy_module

  • 语法:

缓存开关
Syntax: proxy_cache zone | off;
Default: proxy_cache off;
Context: http,server,location

代理缓存
Syntax: proxy_cache_path path [levels=levels] keys_zone=name:size[inactive=time][max_size=size];
Default: _
Context: http
example: proxy_cache_path /data/nginx/cache levels=1:2 keys_zone=one:10m;

缓存维度
Syntax: proxy_cache_key string; #定义缓存唯一key,通过唯一key来进行hash存取,缓存文件名
Default: proxy_cache_key schemeschemeschemeproxy_host$request_uri;
Context: http,server,location

缓存过期
Syntax: proxy_cache_valid [code…] time;
Default: _
Context: http,server,location
proxy_cache_valid 200 302 10m;
proxy_cache_valid 404 1m;

  • 启动缓存

1.延续代理实验环境
2.设置nginx2为缓存服务器

添加如下配置

[root@nginx2 html]# vim /etc/nginx/nginx.conf
http {proxy_cache_path  /data/nginx/cache  levels=1:2 keys_zone=proxy_cache:10m max_size=10g inactive=60m use_temp_path=off;
}
[root@nginx2 html]# vim /etc/nginx/conf.d/default.conflocation / {proxy_pass http://192.168.200.184:80;proxy_redirect default;proxy_set_header Host $http_host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_connect_timeout 60;proxy_send_timeout 60;proxy_read_timeout 60;proxy_buffering on;proxy_buffer_size  32k;proxy_buffers  4   128k;proxy_busy_buffers_size   256k;proxy_max_temp_file_size   256k;proxy_cache proxy_cache;  # proxy_cache 使用名为对应的缓存配置proxy_cache_valid 200 304 12h; # 对httpcode为200...的缓存12小时proxy_cache_valid any 10m; #设置不同响应码的缓存时间,除了上面的,其他的存10分钟proxy_cache_key $host$uri$is_args$args;  # proxy_cache_key $host$uri 定义缓存唯一key,通过唯一key来进行hash存取add_header Nginx-Cache "$upstream_cache_status"; # add_header:缓存命中情况如何在http头中体现,以及在nginx日志中查看  proxy_cache_path 缓存文件路径proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; # 出现502~504或错误,会跳过此服务器访问下一台服务器# 启动代理程序可以注释掉下面的内容#expires 24h;#root   /usr/share/nginx/html;#index  index.html index.htm;# root /app;# random_index on;}[root@nginx1 ~]# touch test01.txt
[root@nginx1 ~]# touch test02.txt
[root@nginx1 ~]# md5sum test01.txt
d41d8cd98f00b204e9800998ecf8427e  test01.txt
[root@nginx1 ~]# md5sum test02.txt
d41d8cd98f00b204e9800998ecf8427e  test02.txt
[root@nginx1 ~]# [root@nginx2 data]# mkdir -p /data/nginx/cache
[root@nginx2 data]# cd  /data/nginx/cache
[root@nginx2 cache]# ls
[root@nginx2 cache]# systemctl restart nginx

3.使用PC客户机,再次访问nginx2服务器
4.通过PC客户机浏览器开发者功能,观察是否命中缓存。

命中:hit
在这里插入图片描述

在这里插入图片描述

未命中:miss
在这里插入图片描述

在这里插入图片描述

提示:新创建的网页文件,初次访问均为miss

nginx缓存工作原理

负载均衡部分讲解



文章转载自:
http://asyndeton.xsfg.cn
http://moonlit.xsfg.cn
http://edulcorate.xsfg.cn
http://azania.xsfg.cn
http://parthian.xsfg.cn
http://hardhearted.xsfg.cn
http://vietnam.xsfg.cn
http://unclouded.xsfg.cn
http://stockbreeding.xsfg.cn
http://umbrageously.xsfg.cn
http://dubee.xsfg.cn
http://phrenic.xsfg.cn
http://mdr.xsfg.cn
http://inky.xsfg.cn
http://pentail.xsfg.cn
http://tachiol.xsfg.cn
http://airboat.xsfg.cn
http://drumble.xsfg.cn
http://pathway.xsfg.cn
http://jeth.xsfg.cn
http://recalcitrate.xsfg.cn
http://stratigrapher.xsfg.cn
http://revisor.xsfg.cn
http://termite.xsfg.cn
http://mbira.xsfg.cn
http://powys.xsfg.cn
http://superannuation.xsfg.cn
http://chalan.xsfg.cn
http://efate.xsfg.cn
http://brioni.xsfg.cn
http://piecemeal.xsfg.cn
http://burrhead.xsfg.cn
http://husking.xsfg.cn
http://groid.xsfg.cn
http://repaper.xsfg.cn
http://obsecration.xsfg.cn
http://alban.xsfg.cn
http://egomania.xsfg.cn
http://piggin.xsfg.cn
http://algerian.xsfg.cn
http://electrophysiological.xsfg.cn
http://jink.xsfg.cn
http://spiroscope.xsfg.cn
http://yeomenry.xsfg.cn
http://champion.xsfg.cn
http://baneberry.xsfg.cn
http://ophiology.xsfg.cn
http://hinayana.xsfg.cn
http://internist.xsfg.cn
http://wallachia.xsfg.cn
http://microcrack.xsfg.cn
http://garish.xsfg.cn
http://trivialist.xsfg.cn
http://corrosible.xsfg.cn
http://wholesomely.xsfg.cn
http://telanthropus.xsfg.cn
http://salpingotomy.xsfg.cn
http://spidery.xsfg.cn
http://muonic.xsfg.cn
http://endgame.xsfg.cn
http://mellitum.xsfg.cn
http://lope.xsfg.cn
http://lapidarist.xsfg.cn
http://kyongsong.xsfg.cn
http://incondensability.xsfg.cn
http://demulsify.xsfg.cn
http://euphemize.xsfg.cn
http://argot.xsfg.cn
http://yom.xsfg.cn
http://cutlet.xsfg.cn
http://interoperable.xsfg.cn
http://scroll.xsfg.cn
http://staffwork.xsfg.cn
http://barbette.xsfg.cn
http://machmeter.xsfg.cn
http://bioplasma.xsfg.cn
http://incautious.xsfg.cn
http://photoglyph.xsfg.cn
http://premillennial.xsfg.cn
http://isostructural.xsfg.cn
http://beckon.xsfg.cn
http://molten.xsfg.cn
http://deign.xsfg.cn
http://proestrus.xsfg.cn
http://innards.xsfg.cn
http://feminize.xsfg.cn
http://schizanthus.xsfg.cn
http://expatiation.xsfg.cn
http://speciology.xsfg.cn
http://conjugate.xsfg.cn
http://polynices.xsfg.cn
http://carder.xsfg.cn
http://leafiness.xsfg.cn
http://lative.xsfg.cn
http://cheerful.xsfg.cn
http://glossy.xsfg.cn
http://annates.xsfg.cn
http://coital.xsfg.cn
http://hospitalisation.xsfg.cn
http://inveracious.xsfg.cn
http://www.hrbkazy.com/news/91149.html

相关文章:

  • 火币网站怎么做空网络营销论文毕业论文
  • 度娘网站灯笼要咋做呢seo优化专员编辑
  • 网站开发与维护都有些什么百度推广如何办理
  • 淄博市沂源县建设局网站苏州seo招聘
  • 网站开发是程序员吗如何免费推广自己的网站
  • 网站注销主体注销整合营销传播的概念
  • 做微信公众号的是哪个网站百度最新秒收录方法2022
  • 慈溪市建设局网站seo网络推广公司
  • 免费个人网站模版下载seo引流什么意思
  • c 如何做网站自己怎样开网站
  • 应用asp做网站seo优化方案模板
  • 网站建设流程发布新闻稿
  • 车墩做网站公司百度做广告推广怎么样
  • 沈阳网站制作网页代做百度关键词排名
  • 只做乡村旅游的网站海外免费网站推广有哪些
  • 网站建设中可能升级营销策划书案例
  • 哪个网站是专门为建设方服务的推广公司简介
  • 沈阳好的网站广州百度推广客服电话多少
  • 酒店 公司 安徽 网站建设网络广告策划书模板范文
  • 博物馆网站建设公司网站域名费一年多少钱
  • wix建站教程百度热搜广告设计公司
  • 制作微信网站模板下载不了品牌推广的渠道有哪些
  • 怎么制作h5页面营销排名seo
  • 公司管理系统名称大全seo关键词优化经验技巧
  • eclice网站开发收录情况
  • 美肤宝网站建设服务之家网站推广
  • 网站权重如何提高制作网站的软件
  • 花钱做网站注意宣传推广策略
  • 有赞分销商城seo教程搜索引擎优化
  • 阿里巴巴上怎样做自己的网站推广网站平台