我发现我的网站有这个问题,但我无法修复它。我尝试了几种方法,比如检查 Nginx 别名指令的父前缀位置是否以目录分隔符结尾,但到目前为止还没有成功。Merge_slashes on - 是默认设置。我读过关于 AppArmour 或 SELinux 的文章。这是可行的方法吗?我有 Ubuntu 18。换句话说,我可以下载这个文件 http://mywebsite.com///etc/passwd 我想避免这种情况。任何帮助都非常感谢。这是我的配置:
server {
listen 80;
server_name
.mysite.com;
return 301 https://mysite.com$request_uri;
}
server {
server_name
www.mysite.com;
listen 443 ssl http2;
ssl_prefer_server_ciphers On;
ssl_session_cache shared:SSL:10m;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_dhparam /etc/ssl/certs/dhparam.pem;
ssl_ciphers '......
ssl_certificate /...crt;
ssl_certificate_key /..key;
return 301 https://mysite.com$request_uri;
}
server {
server_name
mysite.com;
listen 443 ssl http2;
ssl_prefer_server_ciphers On;
ssl_session_cache shared:SSL:10m;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_dhparam /etc/ssl/certs/dhparam.pem;
ssl_ciphers '...
ssl_certificate /...crt;
ssl_certificate_key /.....key;
add_header x-frame-options "SAMEORIGIN" always;
add_header x-xss-protection "1; mode=block" always;
add_header X-Content-Type-Options nosniff;
add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; $
root /var/www/www.mysite.com;
index index.php;
client_max_body_size 10M;
access_log /var/log/nginx/mysite.com.log;
error_log /var/log/nginx/mysite.com.error.log error;
location / {
try_files $uri $uri/ /index.php;
}
location /shopping/ {
index index.php index.html index.htm;
rewrite ^/shop/wp-json/(.*?)$ /shopping/index.php?rest_route=/$1 last;
try_files $uri $uri/ /shop/index.php?q=$uri&$args;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires 24h;
log_not_found off;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~\.(log|save|htaccess|json|csv|txt|xls)$ {
deny all;
error_page 403 =404 / ;
}
location ~* /(?:uploads|files)/.*\.php$ {
deny all;
}