Nginx常见配置记录
Contents
禁止ip访问
server {
listen 80 default;
server_name _;
return 500;
}
or
server {
listen 80 dufault;
server_name _;
rewrite ^(.*) http://www.xxx.cn permanent;
}
or
server {
listen 80 default;
server_name _;
server_name xxx.cn
return 500;
}
域名重定向
server {
listen 80;
server_name xxx.cn;
if ($host = 'xxx.cn' ) {
rewrite ^/(.*)$ http://xx.xxx.com/$1 permanent;
}
}