저는 VPS에 일부 웹 사이트를 호스팅하고 일부는 "정적"이고 일부는 동적입니다 (WordPress). 정적 웹 사이트 (정적 PHP 페이지) "존중"nginx conf, http 섹션에서 설정 한 헤더. 예 :WordPress는 nginx 헤더를 준수하지 않습니다.
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";
add_header X-Cache $upstream_cache_status;
헤더 :
HTTP/1.1 200 OK
Server: nginx
Date: Tue, 16 Sep 2014 17:09:04 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Accept-Encoding
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
X-Cache: HIT
Strict-Transport-Security: max-age=31536000; includeSubdomains;
워드 프레스 웹 사이트 대신 내가 설정이 헤더가 없습니다 :
HTTP/1.1 200 OK
Server: nginx
Date: Tue, 16 Sep 2014 17:08:25 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Accept-Encoding
X-Pingback: http://website.com/xmlrpc.php
Link: <http://wp.me/P4zIfv-2>; rel=shortlink
X-UA-Compatible: IE=Edge,chrome=1
두 웹 사이트는 동일한 가상 호스트 설정을 가지고! 물론 liste, server_name, index ecc .. 다음 위치 :
location/{
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
fastcgi_cache website.com;
fastcgi_cache_valid 200 20m;
fastcgi_cache_bypass $no_cache;
fastcgi_no_cache $no_cache;
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include /etc/nginx/fastcgi.conf;
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
왜 WP에서 이런 현상이 발생합니까?
나는 이미 읽을 위치 블록 안쪽에 넣어하지만 훨씬 이해가되지 않습니다. add_header 지시문은 "일반"http 섹션에 있습니다. 서버 섹션이 아닙니다. 그들은 모든 위치에 적용하면 안됩니까? – MultiformeIngegno
Nginx 지시어는 상위 섹션에서 상속됩니다. 따라서'http'에 위치한 지시어는 모든 서버와 위치에 의해 상속되지 않는 한 상속받습니다. 반면에'server' 섹션에있는 지시문은 덮어 쓰지 않는 한 그 밑에있는 모든 위치 블록에 의해 상속됩니다. – Dayo