
특정 IP 주소로 내 웹사이트에 액세스할 때 단일/다중 HTTP 헤더를 어떻게 설정 해제할 수 있나요? 내 CSP 구성이 일부 로컬 페이지가 제대로 로드되지 않도록 차단하기 때문입니다. 예를 들어 phpMyAdmin이 있지만 CSP가 설정되어 있어 로컬에서 사용할 수 없는 경우입니다.
답변1
다음 구성을 사용하여 IP 주소에 따라 헤더 설정을 해제할 수 있습니다.
# For single ip address. Change the IP address to your needs
<Directory "/path/to/the/folder/which/needs/to/have/this/feature">
<If "%{REMOTE_ADDR} == '127.0.0.1'">
Header always unset HeaderName
</If>
</Directory>
# For multiple IP addresses, remove the top one, and use this one, and change the IP addresses
# to your needs, and add more '||' to use more IP addresses.
<Directory "/path/to/the/folder/which/needs/to/have/this/feature">
<If "%{REMOTE_ADDR} == '127.0.0.1' || %{REMOTE_ADDR} == '1.2.3.4'">
Header always unset HeaderName
</If>
</Directory>
mod_headers가 활성화되어 있는지 확인하세요. 자세한 내용은 확인하세요https://httpd.apache.org/docs/2.4/mod/core.html#if그리고https://httpd.apache.org/docs/2.4/expr.html.
필요에 따라 구성할 수 있지만 주의하고 자신을 제외한 모든 사람에 대해 CSP와 같은 헤더를 비활성화하지 않도록 하십시오.
답변2
지시문이 Header
작동하지 않으면 지시문을 RequestHeader
대신 사용하십시오. 다음은 Apache가 효과가 없는 X-Forwarded-For
역방향 프록시로 사용될 때 헤더 스푸핑을 방지하는 방법의 예입니다 .Header
RequestHeader unset X-Forwarded-For
RemoteIPHeader X-Forwarded-For