说明
一级域名类似于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端口
网友评论