学习nginx配置

19 阅读1分钟

fastcgi_intercept_errors on;

server {
listen  80;
server_name www.abc.com;
rewrite ^(.*)$  https://$host$1 permanent;
}
server {
listen       443;
server_name  www.abc.com;
root   html/www;
index  index.php index.html index.htm;

#https证书
ssl on;
ssl_certificate /application/nginx/conf/key/server.crt;
ssl_certificate_key /application/nginx/conf/key/server.key;

#访问日志
access_log  logs/access_www.log  main;

#隐藏版本号
server_tokens on;

##防盗链
#location ~* .*\.(jpg|gif|swf|flv|wma|wmv|asf|mp3|mmf|zip|rar)$ {      #小括号中不能包含要跳转的图片结尾格式.png,-->否则会进入死循环跳转
#    valid_referers none blocked *.abc.com abc.com www.abc.com;
#    if ($invalid_referer) {
#       #return 403;
#       rewrite ^/  www.abc.com/