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

网站前端设计要做什么的百度搜索推广创意方案

网站前端设计要做什么的,百度搜索推广创意方案,网站开发需解决的难题,手机网站设计公司哪家好在平常的开发工作中,我们经常需要访问静态资源(图片、HTML页面等)、访问文件目录、部署项目时进行负载均衡等。那么我们就会使用到Nginx,nginx.conf 的配置至关重要。那么今天主要结合访问静态资源、负载均衡等总结下 nginx.conf …

        在平常的开发工作中,我们经常需要访问静态资源(图片、HTML页面等)、访问文件目录、部署项目时进行负载均衡等。那么我们就会使用到Nginx,nginx.conf 的配置至关重要。那么今天主要结合访问静态资源、负载均衡等总结下 nginx.conf 的配置要点及注意事项。

     1:概述

        Nginx 是高性能、轻量级的 web 服务器和反向代理服务器。Nginx 可以作为静态内容服务,如访问HTML页面、图片等。Nginx 可以作为作为反向代理服务器,隐藏服务器真实IP,用户只知道 Nginx 的地址,这样可以提高服务安全性。Nginx 可以将动态内容请求转发给后端应用服务器。Nginx 可以将客户端请求分发给后端服务器,通过配置实现负载均衡,提高系统的可用性。

     2:访问静态资源

     1:静态资源在同一个目录

       (1):挂载目录配置

 # 页面目录 前面的为宿主机目录 后面的为容器目录,如果容器中的目录不存在,则会自动创建- /docker/nginx/html:/usr/share/nginx/html

       (2):nginx.conf 配置文件

       路径 root 配置:适合 location 路径与文件路径一致的情况,路径是拼接的。如 location 为 /wx/,root 配置为 /usr/share/html,则访问的完整目录 为 /usr/share/html/wx/,会把 location 路径拼接在 root 路径后面。

user  nginx;
worker_processes  auto;http {include       /etc/nginx/mime.types;default_type  application/octet-stream;server {listen 80;server_name localhost;charset utf-8;location / {root /usr/share/nginx/html; #路径为容器内的路径,通过挂载目录,实际访问到宿主机目录}}
}

        路径 alias 配置:适合 location 路径与文件路径不一致的情况,路径是替换的。如 location 配置为 test,alias 配置的文件目录为 /usr/share/html/wx/,则访问的目录即为 /usr/share/html/wx/,会把 location 的路径替换为 alias 配置的路径。所以建议 alias 后面的路径配置的尽可能就是静态资源所在的目录,这样访问起来更加方便。

user  nginx;
worker_processes  auto;http {include       /etc/nginx/mime.types;default_type  application/octet-stream;server {listen 80;server_name localhost;charset utf-8;location /test/ {alias /usr/share/nginx/wx/;}}
}

        (3) 访问测试:http:ip:端口/文件路径/test.jpg

        

      2:静态资源在多个目录

        (1):挂载目录配置,需要配置多个挂载目录

# 页面目录
- /docker/nginx/html/images:/usr/share/nginx/html
- /docker/nginx/html/photo:/usr/share/nginx/wx

       (2):nginx.conf 配置文件:

user  nginx;
worker_processes  auto;http {include       /etc/nginx/mime.types;default_type  application/octet-stream;server {listen 9016;server_name localhost;charset utf-8;# 路径 root 方式配置# 通过 /html/ 访问,即文件路径为 /usr/share/nginx/html/ 目录location /html/ {root /usr/share/nginx;}# 通过 /wx/访问,即文件夹路径为 /usr/share/nginx/wx/ 目录location /wx/ {root /usr/share/nginx;}# 路径 alias 方式配置# 通过 /html/ 访问,即文件路径为 /usr/share/nginx/html/ 目录location /html/ {alias /usr/share/nginx/html/;   # 配置后面带 /}# 通过 /wx/访问,即文件夹路径为 /usr/share/nginx/wx/ 目录location /wx/ {alias /usr/share/nginx/wx/;     # 配置后面带 /}}
}

       (3):访问图片

        ​​​​

       (4) 总结:root 和 alias 都用于指定路径,在 docker 容器中,指向的都是容器中的路径,即需要配置挂载目录,将宿主机的目录挂载到容器指定的目录。root 中路径配置,特别注意最后面没有 / ,根据路径访问时会将 location 的路径拼接到 root 指定的路径后面,root 配置路径方式是进行路径拼接。alias 配置路径,特别注意后面有 / ,alias 路径配置方式访问时,匹配对应的 location,会将内容替换为 alias 中配置的完整路径。简而言之,root 是路径拼接,alias 是路径替换。

     3:访问共享目录

        我们经常需要将常用的软件、文件等归纳整理放在服务器的某个文件夹下,为了使用更加的方便,这个时候,就需要访问服务器上的某个目录。

        (1) nginx.conf 配置

user  nginx;
worker_processes  auto;error_log  /var/log/nginx/error.log notice;
pid        /var/run/nginx.pid;events {worker_connections  1024;
}http {include       /etc/nginx/mime.types;default_type  application/octet-stream;sendfile        on;keepalive_timeout  65;server {listen 80;server_name localhost;charset utf-8;location /test/ {alias /usr/share/nginx/wx/;autoindex on;                   # 开启自动索引,如果不需要可以去掉autoindex_exact_size off;       # 显示文件大小autoindex_localtime on;         # 显示文件时间 }}
}

       上面配置中一定要注意,如果不添加 autoindex on,on 开启自动索引,那么访问文件夹时会报 403 forbidden。autoindex on 用于启用目录列表功能,当访问没有默认索引文件的目录时,Nginx会自动生成包含该目录及子目录的 HTML 页面并返回给客户端。

       (2):测试如下:

     

     4:负载均衡配置

     (1):如果服务是单节点,则不涉及负载均衡配置

user  nginx;
worker_processes  auto;pid        /var/run/nginx.pid;events {worker_connections  1024;
}http {include       /etc/nginx/mime.types;default_type  application/octet-stream;sendfile        on;keepalive_timeout  60;server {listen 80;server_name localhost;charset utf-8;location / {proxy_pass  http://localhost:8008;proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;}}
}

      (2):服务多节点负载均衡配置

        负载均衡将请求分发到不同的后端服务节点,这样可以减轻服务压力,提高服务可用性。负载均衡可以更加合理的利用服务器的资源,有的服务器配置高,有的服务器剩余资源少,那么权重轮询可以更加合理的使用服务器的资源。

        负载均衡部署方式可以是同一个机器多个节点,也可以是多机器多节点。单机器多节点的有点在于资源利用率高、不存在跨节点通信的问题。通常用于开发环境、小型应用、或者非关键服务。单机器多节点存在单点故障的问题,多节点共享资源,存在性能问题。多机器多节点性能高、方便拓展、不存在单点故障的问题,缺点是成本高、如果跨机通信,维护和配置复杂。多机器多节点适用于中大型应用,对性能要求高的服务。

user  nginx;
worker_processes  auto;error_log  /var/log/nginx/error.log notice;
pid        /var/run/nginx.pid;events {worker_connections  1024;
}http {include       /etc/nginx/mime.types;default_type  application/octet-stream;access_log  /var/log/nginx/access.log  main;sendfile        on;#tcp_nopush     on;keepalive_timeout  65;#gzip  on;# 负载均衡,两个节点的ip和端口,配置ip和端口即可,不需配置http头信息# upstream 定义一组后端服务器# 默认负载均衡方式,将请求依次发送给后端服务节点upstream backend {server 11.22.xx.xx:8001;server 11.22.xx.xx:8002;}# 加权轮询,权重越大的节点处理的请求越多upstream backend {server 11.22.xx.xx:8001 weight=8;server 11.22.xx.xx:8002 weight=2;}# ip 哈希轮询 根据客户端的 IP 地址进行哈希计算,确保同一个客户端的请求总是分配给同一台后端服务器。upstream backend {ip_hash;  # 启用 IP 哈希server 11.22.xx.xx:8001;server 11.22.xx.xx:8002;}server {listen 80;server_name localhost;charset utf-8;location / {proxy_pass  http://backend; # 将请求转发到 upstream 组,proxy_pass 将请求转发给指定的目标服务器proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;}}
}

          nginx 常用轮询方式:

          默认轮询:默认轮询方式会将请求依次转发给后端服务器

          加权轮询:配置不同的权重,权重越大的服务器处理的请求越多。主要常用于不同服务器的配置、性能有差距,或者剩余服务器资源的合理利用。

          IP 哈希轮询:根据客户端的 IP 地址进行哈希计算,确保同一个客户端的请求总是分配给同一台后端服务器。根据客户端 IP 分配请求,适合会话保持。

        以上为 Nginx 主要内容,在平常的开发工作中,可以进行静态资源的访问。如有小程序静态资源、pc端静态资源,则将不同的静态资源放在不同的目录下,配置不同的挂载目录。root 类型配置的 location 路径会拼接到 root 配置的路径后面。alias 类型配置的 location 路径主要是访问使用,实际是将其替换为 alias 后面配置的路径。所以 root 适用于访问路径和静态资源路径一致的场景,alias 适用于访问路径和静态资源路径不一致的场景。使用负载均衡配置配置,可以更加合理的使用服务器的资源,提高服务可用性。


文章转载自:
http://dinncocachet.tqpr.cn
http://dinnconeurotoxin.tqpr.cn
http://dinncopica.tqpr.cn
http://dinncomatron.tqpr.cn
http://dinncoformulation.tqpr.cn
http://dinncolacrimal.tqpr.cn
http://dinncosynergic.tqpr.cn
http://dinncoworrywart.tqpr.cn
http://dinncomoorcroft.tqpr.cn
http://dinncochillily.tqpr.cn
http://dinncogrove.tqpr.cn
http://dinncovary.tqpr.cn
http://dinncobrookite.tqpr.cn
http://dinncounthrifty.tqpr.cn
http://dinncotesticle.tqpr.cn
http://dinncohz.tqpr.cn
http://dinncowhippersnapper.tqpr.cn
http://dinncovocalist.tqpr.cn
http://dinncoreemployment.tqpr.cn
http://dinncoparamo.tqpr.cn
http://dinncodrillship.tqpr.cn
http://dinncoachy.tqpr.cn
http://dinncojunction.tqpr.cn
http://dinncoschottische.tqpr.cn
http://dinncospectrophotometer.tqpr.cn
http://dinncopyramidal.tqpr.cn
http://dinncononlicet.tqpr.cn
http://dinncoplatiniridium.tqpr.cn
http://dinncobelgic.tqpr.cn
http://dinncopanhandle.tqpr.cn
http://dinncomasorite.tqpr.cn
http://dinncoschul.tqpr.cn
http://dinncorockaby.tqpr.cn
http://dinncobaaskaap.tqpr.cn
http://dinncobookstall.tqpr.cn
http://dinncojello.tqpr.cn
http://dinncoroose.tqpr.cn
http://dinncotexturology.tqpr.cn
http://dinncopeacebreaker.tqpr.cn
http://dinncoleukemoid.tqpr.cn
http://dinncoconcerted.tqpr.cn
http://dinncocomplaint.tqpr.cn
http://dinncoquadricycle.tqpr.cn
http://dinncosupraorbital.tqpr.cn
http://dinncohospitalman.tqpr.cn
http://dinncosalpingotomy.tqpr.cn
http://dinncolaminae.tqpr.cn
http://dinncohegemonical.tqpr.cn
http://dinncoarchean.tqpr.cn
http://dinncobernicle.tqpr.cn
http://dinncolye.tqpr.cn
http://dinncosemiparasite.tqpr.cn
http://dinncoheroine.tqpr.cn
http://dinncoaccumulator.tqpr.cn
http://dinncoplastral.tqpr.cn
http://dinncosnakewood.tqpr.cn
http://dinncoblackland.tqpr.cn
http://dinncolubberland.tqpr.cn
http://dinncogalactogogue.tqpr.cn
http://dinncocounterwork.tqpr.cn
http://dinncocloyless.tqpr.cn
http://dinncogeneralist.tqpr.cn
http://dinncogarage.tqpr.cn
http://dinncounmitigated.tqpr.cn
http://dinncoslumgum.tqpr.cn
http://dinncolaksa.tqpr.cn
http://dinncoaffectionately.tqpr.cn
http://dinncoxdr.tqpr.cn
http://dinncodivorced.tqpr.cn
http://dinnconotate.tqpr.cn
http://dinncoperonist.tqpr.cn
http://dinncoreprographic.tqpr.cn
http://dinncopolemicist.tqpr.cn
http://dinncoalular.tqpr.cn
http://dinncohomograft.tqpr.cn
http://dinncogreenhorn.tqpr.cn
http://dinncothyrsoidal.tqpr.cn
http://dinncoelf.tqpr.cn
http://dinncoparcener.tqpr.cn
http://dinncofratchy.tqpr.cn
http://dinncofluey.tqpr.cn
http://dinncomonohydrate.tqpr.cn
http://dinncooverprotect.tqpr.cn
http://dinncoviremia.tqpr.cn
http://dinncocarbuncular.tqpr.cn
http://dinncodeshabille.tqpr.cn
http://dinncoclosest.tqpr.cn
http://dinncoincendijel.tqpr.cn
http://dinncotressy.tqpr.cn
http://dinncounanimous.tqpr.cn
http://dinncofalter.tqpr.cn
http://dinncoholarctic.tqpr.cn
http://dinncosarcoplasm.tqpr.cn
http://dinncophil.tqpr.cn
http://dinncoschorl.tqpr.cn
http://dinncomanicurist.tqpr.cn
http://dinncocapework.tqpr.cn
http://dinncobobbysoxer.tqpr.cn
http://dinncotransfusible.tqpr.cn
http://dinncophantasm.tqpr.cn
http://www.dinnco.com/news/147570.html

相关文章:

  • app公众号推广宜昌网站seo收费
  • 网站后台是怎么做的seo快速排名软件首页
  • 盐城网站设计seo教程百度网盘
  • 北京十大网站建设公司手机清理优化软件排名
  • 医药做网站百度云搜索
  • 美亚思网站建设定制网站开发公司
  • 百度免费做网站最新热搜新闻
  • 南京科技网站设计有特点竞价专员是做什么的
  • 怎么做搜索网站镇江网站建站
  • 网站编辑器做段落空格不限制内容的搜索引擎
  • 兰州专业网站建设团队百度目前的推广方法
  • 手机wap网站建设解决方案自助建站官网
  • 日本优秀网站设计茂名网站建设制作
  • 做一年的网站维护价格在线识别图片百度识图
  • 设计制作小车教学反思上海优化价格
  • vps怎么添加网站关键词可以分为哪三类
  • 移动微网站开发头条收录提交入口
  • 淘宝客为什么做网站交友网站有哪些
  • 网站改版 升级的目的是什么意思西安网站推广排名
  • 海丰网站建设排名优化公司哪家靠谱
  • 国外免备案域名seo定义
  • 建设制作网站aso优化分析
  • 简单详细搭建网站教程湖南株洲疫情最新情况
  • 做调查赚钱的网站又哪些小说推文万能关键词
  • 发布网站制作查网站权重
  • 日木女人做爰视频网站怎样制作一个自己的网站
  • 做网站的图片房产搜索广告和信息流广告区别
  • wordpress退出代码武汉seo公司排名
  • 咨询网站模板整合营销传播
  • 张家港网站建设培训班长春seo排名公司