Nginx配置同一个域名http与https两种方式都可访问
##配置
http://test.pay.joyhj.com
https://test.pay.joyhj.com
两者都可访问
# vim /usr/local/nginx/conf/vhost/test.pay.joyhj.com.conf
server
{
listen 80;
listen 443 ssl; ##把ssl on;这行注释掉, ssl写在443端口后面, 这样http和https的链接都可以用
server_name test.pay.joyhj.com;
index index.html index.htm index.php;
root /data/www/hjtestpay;
charset utf-8;
location ~.*\.(swf|xml|mp3|png|jpg|gif|data)$ {
expires max;
}
location ~.*\.(css|js|mx)$ {
expires 96h;
}
location ~* \.(bak|save|sh|sql|mdb|svn|git|old)$ {
#rewrite ^/(.*)$ $host permanent;
return 403;
}
location ~ .*\.php$ {
include fastcgi.conf;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
expires off;
}
# ssl on; ##把ssl on;这行注释掉, ssl写在443端口后面, 这样http和https的链接都可以用
ssl_certificate /usr/local/nginx/ssl/test.pay.joyhj.com_cert.crt;
ssl_certificate_key /usr/local/nginx/ssl/test.pay.joyhj.com.key;
access_log /data/logs/test.pay.joyhj.com.access.log access;
error_log /data/logs/test.pay.joyhj.com.error.log warn;
}