linux 跟阿铭学linux nginx常用

nginx常用配置


linux 跟阿铭学linux nginx常用
image.png

linux 跟阿铭学linux nginx常用
image.png

linux 跟阿铭学linux nginx常用
image.png

include vhost/*.conf

用户认证
location / {
auth_basic "Auth"
auth_basic_user_file /usr/local/nginx/conf/htpasswd
}

server {
listen 80;
server_name test.com test.com2;
index index.html index.jsp;
root /data/ddd
if (linux 跟阿铭学linux nginx常用http://www.123.com/$1 permanent;
}
}
permanent = [R=301]
redirect = [R=302]

access_log /tmp/aa.log combinated_realip;

kill -HUP cat $nginx_pid
location ~ .*.(gif|jpg|jpeg|png|bmp|swf)linux 跟阿铭学linux nginx常用{
expires 12h;
access_log off;
}

nginx 图片防盗链
location ~* ^.+.(gif|jpg|png|swf|flv|rar|zip|doc|pdf|gz|bz2|jpeg|bmp|xls)linux 跟阿铭学linux nginx常用invalid_referer){
return 403;
}
access_log off;
}

location /data/{
allow 192.168.1.1;
allow 172.12.0.0;
deny all;
}

if ($http_user_agent ~ 'Spider/Tomato'){
return 403;
}

linux 跟阿铭学linux nginx常用
image.png

proxy_pass http://xx;
proxy_set_header Host linux 跟阿铭学linux nginx常用remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forward_for;

upstream aa{
ip_hash;
server 33:33;
server xx:ss;
}

server {
ssl on;
ssl_certificate xx.crt;
ssl_certificate_key xx.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
}