programing

nginx가 있는 워드프레스 색인에서는 403이 금지되어 있으며, 나머지 페이지는 정상적으로 동작합니다.

starjava 2023. 2. 21. 23:19
반응형

nginx가 있는 워드프레스 색인에서는 403이 금지되어 있으며, 나머지 페이지는 정상적으로 동작합니다.

현재 EC2 인스턴스를 호스팅하고 있는 서버상의 사이트 중 하나가 DDoSed이기 때문에 새로운 EC2 인스턴스에 블로그를 셋업하고 있습니다.nginx에 문제가 있습니다.인덱스에는 403 이외의 모든 페이지가 표시되거나 페이지에는 404 이외의 인덱스가 표시되기 때문입니다(사용하는 구성에 따라 다름).

nginx 설정은 다음과 같습니다.

server {
    listen       80;

    server_name  www.test.com;
    server_name  test.com;
    root /www/blog;

    include conf.d/wordpress/simple.conf;
}

simple.conf:

location = /favicon.ico {
            log_not_found off;
            access_log off;
    }

    location = /robots.txt {
            allow all;
            log_not_found off;
            access_log off;
    }

    location / {
            # This is cool because no php is touched for static content. 
            # include the "?$args" part so non-default permalinks doesn't break when using query string
            try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
            #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
            include fastcgi.conf;
            fastcgi_intercept_errors on;
            fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
    }

    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
            expires max;
            log_not_found off;
    }

try_files $uri $uri/ /index.php를 변경하면 어떻게 됩니까?$165s; 인덱스.exex.dex는 첫 페이지가 정상적으로 작동하고 나머지는 404가 됩니다.그렇게 놔두면 1면이 403이에요.

에러 로그를 다음에 나타냅니다.

2013/08/07 19:19:41 [error] 25333#0: *1 directory index of "/www/blog/" is forbidden, client: 64.129.X.X, server: test.com, request: "GET / HTTP/1.1", host: "www.test.com"

이 디렉토리는 nginx 사용자의 경우 755입니다.

drwxr-xr-x 6 nginx nginx  4096 Aug  7 18:42 blog

제가 잘못한 게 있나요?

감사합니다!

더하다index index.php;서버 블록에서 동작하지 않으면$uri/하고 싶지 않으니까autoindex on


편집: Just noticed that you already figured out your problem, so I'll add the reasoning behind it, the reason why you needed autoindex on; is because without it nginx will follow the try_files rules,

  1. 다음 파일이 있는지 확인합니다./그리고 당연히 실패합니다.
  2. 라는 디렉토리가 있는지 확인합니다./(루트를 추가하면 =)/www/blog/이 체크는 성공하기 때문에 폴더 내용 일람을 시도합니다.
  3. 지정하지 않으셨기 때문에autoindex on;디폴트로는 nginx는 디렉토리 리스트를 금지하므로 403의 금지된 오류가 반환됩니다.
  4. 사이트의 나머지 부분은 정상적으로 동작합니다.이것은, 이 기능이 실패했기 때문입니다.$uri/테스트 또는 도달하지 않는 경우라고 하는 폴더가 없을 수 있습니다.image.jpg또는stylesheet.css기타.

{} 위치가 아닌 {} 서버 정의에 index.php가 필요했던 것 같습니다.

CMS 에 인수를 송신하는 것을 허가하고 있지 않은 것 같습니다.따라서 데이터베이스에서 정보를 가져와 403 페이지로 리다이렉트 하는 이 uris는 표시되지 않습니다.

언급URL : https://stackoverflow.com/questions/18111607/403-forbidden-on-wordpress-index-with-nginx-the-rest-of-the-pages-work-fine

반응형