zoukankan      html  css  js  c++  java
  • 马哥博客作业第十九周

    1、实现永久重定向,当用户访问 www.magedu.org 这个域名时我想让他跳转到 www.magedu.com 的主页面,请写出配置过程

    server{
    listen 80   ;
    server_name www.magedu.org;
    
        location / {
            root /data/nginx/html;
            index index.html;
            rewrite / http://www.magedu.com permanent;
        }
    }

     

    2、rewrite案例-判断文件是否存在,要求:当用户访问到公司网站的时输入了一个错误的 URL ,可以将用户重定向至 www.magedu.com 官网首页。请写出配置过程

    server{
    listen 80   ;
    server_name www.magedu.org;
    location / {
            root /data/nginx/html;
            index index.html;
            if (!-e $request_filename) {
                rewrite .* http://www.magedu.com/index.html;                             
            }
    }

    3、用 nginx 做一个代理服务器,server_name 为 www.magedu.org,代理后端两台 apache 服务器。并且要求使用最少连接调度算法实现,这样才能做到后端 apache 服务器的压力大到均衡

    nginx 服务器:10.0.0.105
    
    yum install nginx -y
    
    systemctl enable --now nginx 
    
    vim /etc/nginx/nginx.conf
    
    
    
    http{
      include /etc/nginx/conf.d/*.conf upstream webserver { least_conn; server
    10.0.0.106; server 10.0.0.107; } }

      vim /etc/nginx/conf.d/web.conf

      server {
         listen 80;
         server_name www.magedu.org;
         location / {
         index index.html index.htm;
         root /var/www/html;
        }
      location /web {
          index index.html index.htm;
          proxy_pass http://webserver/;
           }

      }

    apache1 10.0.0.106
    yum install -y httpd 
    
    systemctl enable --now httpd
    
    echo 10.0.0.106 > /var/www/html/index.html
    
    apache1 10.0.0.107
    yum install -y httpd 
    
    systemctl enable --now httpd
    
    echo 10.0.0.107 > /var/www/html/index.html

      

  • 相关阅读:
    SendInput模拟键盘输入的问题 <转>
    tinyMce3.21 使用随笔
    ORM的一些思考
    VS2008 , 1330 , 数字签名错误.
    .Net Reflector 工具 过期后使用小工具。
    就当是一个新的设计模式!
    OpenSUSE 11 下 Mono 2 开发笔记。
    转:)CNBlogs引用第三方组(控)件明细^_^
    DBLinq ,没实现 Log !
    DotNet 的一些知识点
  • 原文地址:https://www.cnblogs.com/huangguangrui/p/13808960.html
Copyright © 2011-2022 走看看