Nginx rewrite

多if
server 80 里添加rewrite ^(.*)https://host$1 permanent;

即:

server {

listen 80;

server_name test.beeae.com;

autoindex on;

sendfile on;

tcp_nopush on;

set $flag '';

if ($host = 'www.demo.kediantong.com'){

set $flag 1;

}

if ($host = 'baealloc.demo.kediantong.com'){

set $flag 1;

}

if ($host = 'baeimage.demo.kediantong.com'){

set $flag 1;

}

if ($host = 'baefile.demo.kediantong.com'){

set $flag 1;

}

if ($host = 'baeconfig.demo.kediantong.com'){

set $flag 1;

}

if ($host = 'baerpcserver.demo.kediantong.com'){

set $flag 1;

}

if ($host = 'api.demo.kediantong.com'){

set $flag 1;

}

if ($host = 'ac01.demo.kediantong.com'){

set $flag 1;

}

if ($host = 'ic01.demo.kediantong.com'){

set $flag 1;

}

if ($host = 'sysmanage.demo.kediantong.com'){

set $flag 1;

}

if ($flag != 1){

rewrite ^(.*)https://host$1 permanent;

}

location / {

root /data/clients;

autoindex on;

sendfile on;

tcp_nopush on;

}

}

server {

listen 443 ssl;

ssl_certificate /data/nginxhttps/server.crt;

ssl_certificate_key /data/nginxhttps/server.key;

server_name test.beeae.com;

autoindex on;

sendfile on;

tcp_nopush on;

location / {

root /data/clients;

autoindex on;

sendfile on;

tcp_nopush on;

}

}

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 一個人 坐在安靜的角落 回想著 曾經走過的滴滴落落 關於我 不知該向誰訴說 這一個 渐失自我的迷途者 那時候 我會...
    筱伟哎阅读 1,924评论 0 0
  • 1. 微博热搜榜上又出现了胡杏儿和黄宗泽的名字,热搜帖题目为为“胡杏儿曾邀请黄宗泽参加婚礼”。 帖中提到胡杏儿在日...
    我是九毛阅读 4,921评论 1 12
  • 《城南花已开》是一首给我感触颇深的纯音乐,在不知道这个歌曲背后的故事之前,我对这首纯音乐感觉是平静...
    森屿_e2cc阅读 11,703评论 0 3
  • 2015年的九月份,大学刚开学。那时候我们都不认识对方,在开学一周过后我回了一趟家,再次回学校的那次也是我第一次自...
    JIANGSHUFEN阅读 2,939评论 0 0