美文网首页
phpstudy 配置nginx支持SNI多个二级域名共用一个i

phpstudy 配置nginx支持SNI多个二级域名共用一个i

作者: cc_a818 | 来源:发表于2020-04-21 15:21 被阅读0次

说明

一级域名类似于baidu.com这样的,像www.biadu.com、tieba.baidu.com这样的属于二级域名,我们平时买的都是一级域名,有了一级域名之后对于二级域名我们是可以根据自己的需要随意配置的,我们的目的是配置出http(s)://www.xxxx.cn和http(s)://blog.xxxx.cn这样的二级可以用http(s)访问的域名。

1.下载你的两个CA证书,解压选择nginx目录conf下的两个文件

证书路径

2.然后修改nginx.conf文件:

# 配置访问www.xxxx.cn的请求

upstream www.test.com{

        server 168.149.165.163:80;

      }

    server {

        listen      443 ssl;

        server_name  www.test.com;

       root    "C:/phpStudy/PHPTutorial/WWW";

        ssl                  on;

        ssl_certificate      C:/phpStudy/PHPTutorial/nginx/conf/1_www.test.com_bundle.crt;

        ssl_certificate_key  C:/phpStudy/PHPTutorial/nginx/conf/2_www.test.com.key;

        ssl_session_timeout  5m;

        ssl_protocols  SSLv2 SSLv3 TLSv1;

      ssl_ciphers  HIGH:!aNULL:!MD5;

        ssl_prefer_server_ciphers  on;

        location / {

    proxy_pass http://www.test.com;

            #index  index.html index.htm index.php l.php;

    try_files $uri $uri/ /index.php?$query_string;

            if (!-e $request_filename) {

              rewrite ^/(.*)$ /index.php/$1 last;

            }

          #autoindex  off;

        }

        location ~ \.php(.*)$  {

            fastcgi_pass  127.0.0.1:9000;

            fastcgi_index  index.php;

            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;

            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

            fastcgi_param  PATH_INFO  $fastcgi_path_info;

            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;

            include        fastcgi_params;

        }

    }

//第二个域名配置

    upstream m.test.com{

        server 168.149.165.163:80;

      }

    server {

        listen      443 ssl;

        server_name  m.test.com;

#root    "C:/phpStudy/PHPTutorial/WWW/Uploads";

        ssl                  on;

        ssl_certificate      C:/phpStudy/PHPTutorial/nginx/conf/1_m.test.com_bundle.crt;

        ssl_certificate_key  C:/phpStudy/PHPTutorial/nginx/conf/2_m.test.com.key;

        ssl_session_timeout  5m;

        ssl_protocols  SSLv2 SSLv3 TLSv1;

      ssl_ciphers  HIGH:!aNULL:!MD5;

ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

        ssl_prefer_server_ciphers  on;

      location / {

            #root  html;

            #index  index.html index.htm;

            proxy_pass http://m.test.com;

        }

    }

此处第二个域名为二级域名,通过绑定模块访问

这样就成功将访问http(s)://www.xxxx.cn、http(s)://blog.xxxx.cn的80端口转发到443端口

相关文章

网友评论

      本文标题:phpstudy 配置nginx支持SNI多个二级域名共用一个i

      本文链接:https://www.haomeiwen.com/subject/temuihtx.html