• Nginx配置域名转发实例


    域名:cps.45wan.com   所在阿里云主机:123.35.9.12

    45wan没有在阿里云备案

    67wan已经在阿里云备案

    阿里云主机(假如123.35.9.12)上原来的nginx配置:

    server {
    listen 80;
      server_name cps.45wan.com;
      root /home/web/cps.45wan.com/htdocs/www;

      location / {
        root /home/web/cps.45wan.com/htdocs/www;
      }

      location ~ .php$ {
        root /home/web/cps.45wan.com/htdocs/www;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /home/web/cps.45wan.com/htdocs/www$fastcgi_script_name;
        include fastcgi_params;
      }
    }

    由于45wan.com没有在阿里备案,因此cps.45wan.com解析到阿里云主机123.35.9.12后,访问此域名会被阿里拦截

    为了能快速访问此域名,使用nginx域名转发解决

    找一台非阿里云的服务器(假如96.18.150.25)新建一个cps.45wan.com的配置

    server {
      server_name cps.45wan.com;
      set $docRoot /home/web/cps.45wan.com;  #此目录为空即可,不需要存在文件
      root $docRoot;
      index index.html;


      location / {
        proxy_pass http://cps.67wan.com ;
      }

    }

    然后在DNSPOD更改解析cps.45wan.com到96.18.150.25

    再回到阿里云主机(123.35.9.12)上修改nginx配置

    server {
      listen 80;
      # server_name cps.45wan.com;
      server_name cps.67wan.com;
      root /home/web/cps.45wan.com/htdocs/www;

      location / {
      root /home/web/cps.45wan.com/htdocs/www;
      }

      location ~ .php$ {
        root /home/web/cps.45wan.com/htdocs/www;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /home/web/cps.45wan.com/htdocs/www$fastcgi_script_name;
        include fastcgi_params;
      }
    }

     修改完毕reload一下nginx重新访问cps.45wan.com即可正常访问!

  • 相关阅读:
    JMeter学习-016-思路篇之-山重水复柳暗花明
    JMeter学习-015-JMeter 断言之-Bean Shell Assertion
    JMeter学习-014-JMeter 配置元件实例之
    Fiddler-008-简单模拟性能测试
    Fiddler-007-修改HTTP请求响应数据
    Fiddler-006-修改HTTP请求参数
    JMeter学习-013-JMeter 逻辑控制器之-如果(If)控制器
    JMeter学习-012-JMeter 配置元件之-HTTP Cookie管理器-实现 Cookie 登录
    JMeter学习-011-JMeter 后置处理器实例之
    JMeter学习-010-JMeter 配置元件实例之
  • 原文地址:https://www.cnblogs.com/fjping0606/p/4607871.html
Copyright © 2020-2023  润新知