需求:
由于业务需求:客户在浏览器中输入 drift.drifter.com 后,实际打开的网站 为 https://www.drifter.com/we-live/drifter
思路分析 :
第一:需要实现 不论是http 还是https 都能实现跳转。
第二:带路径实现跳转
server {
listen 80;
server_name drift.drifter.com;
rewrite ^ https://$server_name$request_uri? permanent;
}
server {
listen 443 ssl;
server_name drift.drifter.com;
location = /favicon.ico {
return 404;
}
if ( $http_host ~* "^(.*)") {
set $domain $1;
rewrite ^(.*) https://www.drifter.com/we-live/drifter break;
}
charset utf-8;
ssl_certificate /root/project/ssl/drift.crt;
ssl_certificate_key /root/project/ssl/drift.key;
ssl_session_timeout 5m;
access_log /var/log/nginx/live_access.log;
error_log /var/log/nginx/live_error.log;
}
以上便是配置