Nginx配置http强制跳转到https
2016-07-26 12:40
741 查看
目的:访问http://sdk.open.test.com/时强制自动跳转到https://sdk.open.test.com/
修改nginx站点配置文件sdk.open.test.com.conf
server
{
listen 80;
server_name sdk.open.test.com;
return 301 https://$server_name$request_uri;
}
server
{
listen 443 ssl;
server_name sdk.open.test.com;
index index.html index.htm index.php;
root /data/www/web/;
charset utf-8;
location ~.*\.(swf|xml|mp3|png|jpg|gif|data)$ {
expires max;
}
location ~.*\.(css|js|mx)$ {
expires 96h;
}
location ~ /.svn/ {
deny all;
}
location ~ .*\.php$
{
include fastcgi.conf;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
expires off;
}
ssl on;
ssl_certificate /usr/local/nginx/ssl/ea93balk25xh3f9.crt;
ssl_certificate_key /usr/local/nginx/ssl/9yrt62bv1z4s35la.key;
access_log /data/logs/sdk.open.test.com.access.log access;
error_log /data/logs/sdk.open.test.com.error.log warn;
}
修改nginx站点配置文件sdk.open.test.com.conf
server
{
listen 80;
server_name sdk.open.test.com;
return 301 https://$server_name$request_uri;
}
server
{
listen 443 ssl;
server_name sdk.open.test.com;
index index.html index.htm index.php;
root /data/www/web/;
charset utf-8;
location ~.*\.(swf|xml|mp3|png|jpg|gif|data)$ {
expires max;
}
location ~.*\.(css|js|mx)$ {
expires 96h;
}
location ~ /.svn/ {
deny all;
}
location ~ .*\.php$
{
include fastcgi.conf;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
expires off;
}
ssl on;
ssl_certificate /usr/local/nginx/ssl/ea93balk25xh3f9.crt;
ssl_certificate_key /usr/local/nginx/ssl/9yrt62bv1z4s35la.key;
access_log /data/logs/sdk.open.test.com.access.log access;
error_log /data/logs/sdk.open.test.com.error.log warn;
}
相关文章推荐
- 尝试深入了解Async-http
- 图解HTTPS
- android-async-http下载zip文件存储或解压
- TCP协议连接的11种状态浅谈
- http url get方式传递数组参数
- C++网络摄像头数据的获取与显示 (续)
- SpringBoot启用HTTPS协议
- RxJava实战演示2,获取网络图片
- Http请求util类
- #NOIP 2014#day.2 T1 无限网络发射器选址
- HTTPS系列之RSA算法
- 警告: No mapping found for HTTP request with URI [] in DispatcherServlet with name
- Http/FTP多线程断点续传下载
- 每日安全简讯(20160726)
- Pjsip通信如何使用TCP协议
- C++网络摄像头数据的获取与显示
- TCP中URG和PSH的含义及区别
- python下的socket网络编程
- codeblocks网络编程不识别socket等
- HTTP协议详解