나는 nginx 서버를 가지고 있으며 모두 finde 작동하는 것처럼 보이지만 디렉토리에 대한 인증을 추가하면 서버가 PHP 코드를 다운로드로 반환합니다.
server {
listen 80 default_server;
listen [::]:80 default_server;
listen 443 ssl;
root /var/www/html;
index index.php index.html index.htm;
server_name _;
location ^~ /auth/ {
try_files $uri $uri/ =404;
auth_basic "Auth";
auth_basic_user_file /etc/nginx/.htpasswd;
}
location / {
try_files $uri $uri/ =404;
}
location ~ /\. {
deny all;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
location ~ /(config\.php|common\.php|cache|files|images/avatars/upload|includes|store) {
deny all;
return 403;
}
location ~* \.(gif|jpe?g|png|css)$ {
expires 30d;
}
add_header X-Frame-Options DENY;
add_header X-Content-Type-Options nosniff;
add_header Strict-Transport-Security 'max-age=31536000; preload';
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://ssl.google-analytics.com https://assets.zendesk.com https://connect.facebook.net; img-src 'self' https://ssl.google-analytics.com https://s-static.ak.facebook.com https://assets.zendesk.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com https://assets.zendesk.com; font-src 'self' https://themes.googleusercontent.com; frame-src https://assets.zendesk.com https://www.facebook.com https://s-static.ak.facebook.com https://tautt.zendesk.com; object-src 'none'";
ssl_stapling on;
ssl_stapling_verify on;
resolver 8.8.4.4 8.8.8.8 valid=300s;
resolver_timeout 10s;
location ~ /\.ht {
deny all;
}
}
위치가 없으면 ^ ~ / auth / 모든 것이 정상입니다. 나는 다른 브라우저에서 이것을 경험했습니다.
nginx
위치를 선택 하여 요청 을 처리합니다 . 새로운 location
것은 PHP를 실행하는 데 필요한 코드를 포함하지 않습니다. 디렉토리 내에서 PHP를 처리하려면 중첩 위치 블록 을 추가해야합니다 /auth/
.
location ^~ /auth/ {
try_files $uri $uri/ =404;
auth_basic "Auth";
auth_basic_user_file /etc/nginx/.htpasswd;
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
}
...
location ~ \.php$ { ... }
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다