使用Nginx将域名下的所有http请求转换为https请求,实际上就是将http虚拟主机的所有请求都转发到https虚拟主机上。
配置示例如下所示:
# the jtyp http_https-server
server {
listen 80;
server_name jtyp.gdliulan.com;
rewrite ^(.*) https://$server_name$1 permanent;
}
server {
listen 443 ssl;
server_name jtyp.gdliulan.com;
ssl_certificate /usr/web/jtyp/2502643_jtyp.gdliulan.com.pem;
ssl_certificate_key /usr/web/jtyp/2502643_jtyp.gdliulan.com.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
root "/usr/web/jtyp";
location / {
index index.html index.htm index.php default.php;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$1 last;
}
#autoindex off;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
locat