请教怎样禁止访问域名根目录,其他非根目录正常访问
请教怎样禁止访问域名根目录,其他子目录正常访问例如:www.abc.com打开返回403
www.abc.com/aa/1.html等这些都能正常访问
http配置的时候
我在nginx的server最后增加下面的
location = / {return 403;}
这样就能实现根目录打不开,非根目录正常打开
但是我换成https
这样配置就全部都不能访问,请教军哥大神是怎么回事?
http其他作用的话,https是一样的,只不过https多个ssl证书的设置
要不你贴一下配置文件看看 licess 发表于 2019-3-30 11:19
http其他作用的话,https是一样的,只不过https多个ssl证书的设置
要不你贴一下配置文件看看 ...
server
{
listen 80;
#listen [::]:80;
server_name www.aaa.com ;
index index.html index.htm index.php default.html default.htm default.php;
root/home/wwwroot/aaa;
return 301 https://www.aaa.com$request_uri;
include rewrite/none.conf;
#error_page 404 /404.html;
# Deny access to PHP files in specific directory
#location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }
include enable-php.conf;
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ /.well-known {
allow all;
}
location ~ /\.
{
deny all;
}
access_log off;
}
server
{
listen 443 ssl http2;
#listen [::]:443 ssl http2;
server_name www.aaa.com ;
index index.html index.htm index.php default.html default.htm default.php;
root/home/wwwroot/aaa;
ssl on;
ssl_certificate /usr/local/nginx/conf/ssl/www.aaa.com/fullchain.cer;
ssl_certificate_key /usr/local/nginx/conf/ssl/www.aaa.com/www.aaa.com.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers "EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5";
ssl_session_cache builtin:1000 shared:SSL:10m;
# openssl dhparam -out /usr/local/nginx/conf/ssl/dhparam.pem 2048
ssl_dhparam /usr/local/nginx/conf/ssl/dhparam.pem;
include rewrite/none.conf;
#error_page 404 /404.html;
# Deny access to PHP files in specific directory
#location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }
include enable-php.conf;
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ /.well-known {
allow all;
}
location ~ /\.
{
deny all;
}
access_log off;
location = / {
return 403;
}
}
licess 发表于 2019-3-30 11:19
http其他作用的话,https是一样的,只不过https多个ssl证书的设置
要不你贴一下配置文件看看 ...
没什么特别的配置,就加了
location = / {
return 403;
}
这样就全部页面都是403
其他的基本都是lnmp自动生成的
蓝色枫 发表于 2019-4-1 16:00
没什么特别的配置,就加了
配置上没问题,这段代码也只匹配到 / 匹配不到其他页面不会导致其他页面403
页:
[1]