- 取得連結
- X
- 以電子郵件傳送
- 其他應用程式
I want to user access deny each file under .git directory
there are many virtual hosts conf in my /etc/nginx/conf.d/
we can add some configs and include them.
create a global server settings file,put it into
/etc/nginx/conf.d/global/server_deny.conf
change virtual host conf
done and enjoy it~!
there are many virtual hosts conf in my /etc/nginx/conf.d/
server {
server_name aaa.xxx.com
#deny access to .git
location ~ /\.git {
deny all;
}
}
server {
server_name bbb.xxx.com
#deny access to .git
location ~ /\.git {
deny all;
}
}
server {
server_name ccc.xxx.com
#deny access to .git
location ~ /\.git {
deny all;
}
}
this is the simple way to work.but not the better way to work.we can add some configs and include them.
create a global server settings file,put it into
/etc/nginx/conf.d/global/server_deny.conf
#/etc/nginx/conf.d/global/server_deny.conf
#deny access to .git
location ~ /\.git {
deny all;
}
change virtual host conf
server {
server_name aaa.xxx.com
include /etc/nginx/conf.d/global/*.conf;
}
server {
server_name bbb.xxx.com
include /etc/nginx/conf.d/global/*.conf;
}
server {
server_name ccc.xxx.com
include /etc/nginx/conf.d/global/*.conf;
}
$ service nginx restart
done and enjoy it~!
留言