說明
一級域名類似于baidu.com這樣的韩玩,像www.biadu.com樱报、tieba.baidu.com這樣的屬于二級域名阵面,我們平時買的都是一級域名绣否,有了一級域名之后對于二級域名我們是可以根據(jù)自己的需要隨意配置的誊涯,我們的目的是配置出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端口轉(zhuǎn)發(fā)到443端口