5

403 오류가 발생할 때마다 오류 페이지를 /temp/www/error403.html에 표시하려고합니다.nginx로 맞춤 403 오류 페이지를 반환하십시오.

사용자가 https (ssl)를 통해 사이트에 액세스하려고 시도 할 때마다 해당 IP가 blovkips.conf 파일에 있지만, 여전히 nginx의 기본 오류 페이지가 표시됩니다. 다른 서버 (차단없이)에 대해 동일한 코드가 있으며 작동합니다.

IP가 사용자 정의 403 페이지에 액세스하는 것을 차단합니까? 그렇다면 어떻게 작동시킬 수 있습니까?

server { 
    # ssl 
    listen    443; 
    ssl     on; 
    ssl_certificate  /etc/nginx/ssl/site.in.crt; 
    ssl_certificate_key /etc/nginx/ssl/site.in.key; 
    keepalive_timeout 70; 

    server_name localhost; 


    location/{ 
      root /temp/www; 
      index index.html index.htm; 
} 

# redirect server error pages to the static page 
error_page 403 /error403.html; 
# location = /error403.html { 
#   root /temp/www; 
# } 

    # add trailing slash if missing 
    if (-f $document_root/$host$uri) { 
      rewrite ^(.*[^/])$ $1/ permanent; 
    }  

    # list of IPs to block 
    include blockips.conf; 
} 

편집 : 수정 error_page 코드 403-504하지만 난 여전히 같은 문제에만 오류 코드를 보내는으로 나열된 구성에서 않니가, 거기처럼 보이는

답변

0

가에서 (503) ("서비스를 사용할 수 없음") 당신은 아마 사용하고자하는 ("금지") (403)에 대한 있도록 사용자 정의 페이지 :

error_page 403 /error403.html 
+0

(여기서 blockips.conf 파일은'deny 1.2.3.4;'와 같은 각 줄과 함께 유효하다고 가정합니다.) – ewall

+0

예.conf가 옳다면 내가 아는 바로는, 나는 이것을 주석 처리하지 않았다. (테스트 용) – Mint

+0

좋아, 내가 지금 재부팅을 완료하고 403 '403 금지 된 nginx'다른 아이디어를 얻을 설정 파일을 편집 할 수 있습니까? – Mint

1

웹 서버에서 액세스가 금지 된 403 "금지"오류를 서버에 넣으려고하는 것이 문제 일 수 있습니다. Nginx는 error_page 지시문을 내부 리디렉션으로 처리합니다. 그래서 그것은 또한 금지 된 서버 https://example.com/error403.html에 노력하고 있습니다.

error_page 403 http://example.com/error403.html 

또는 오류 페이지 경로의 위치에 옵션을 필요한 "허용 된 액세스"를 추가 :

그래서 당신은하지 다음과 같이 HTTPS에서 제공 오류 페이지를 확인해야합니다. 이를 테스트하는 방법은 /error403.html 페이지에 직접 액세스하는 것입니다. 그런 식으로 액세스 할 수 없으면 누군가가 실제 403 오류를 얻으면 작동하지 않습니다.

0

나는 똑같은 문제가있다. 요점은 서버 컨텍스트 레벨 (또는 가상 호스트 레벨)에서 ip whitelist를 구현했기 때문에 모든 위치에서도 이와 같이 사용할 수있다 (기본 /403.html 원 '이 t)는 액세스 할 수 :

제외 conf.d 파일 샘플
server { 
    listen  *:443 ssl; 
    server_name mydomain.com ; 
    error_page 403 /403.html; 
    ..... 
    if ($exclusion = 0) { return 403; } #implemented in another conf.d files (see below) 
    location ~ \.php$ { 
    root   /var/www/vhosts/mydomain.com/httpdocs; 
    include  /etc/nginx/fastcgi_par 
    fastcgi_pass 127.0.0.1:9000; 
    fastcgi_connect_timeout 3m; 
    fastcgi_read_timeout 3m; 
    fastcgi_send_timeout 3m; 
    } 
    location /403.html { 
    root  /usr/share/nginx/html; 
    allow all; 
    } 

    ... 
} 

:

server { 
    listen  *:443 ssl; 
    server_name mydomain.com ; 
    error_page 403 /403.html; 
    ..... 
    location ~ \.php$ { 
    if ($exclusion = 0) { return 403; } 
    root   /var/www/vhosts/mydomain.com/httpdocs; 
    include  /etc/nginx/fastcgi_par 
    fastcgi_pass 127.0.0.1:9000; 
    fastcgi_connect_timeout 3m; 
    fastcgi_read_timeout 3m; 
    fastcgi_send_timeout 3m; 
    } 
    location /403.html { 
    root  /usr/share/nginx/html; 
    allow all; 
    } 

    ... 
} 
:

geo $exclusion { 
    default 0; 
    10.0.0.0/8 Local network 
    80.23.120.23 Some_ip 
    ... 
} 

그 문제를 해결하려면 단순히 위치 수준에서 수익 403 (컨텍스트)을 할

저에게 맞습니다.