* 개요
- nginx 버전: 1.18.0
- nginx - php 설정을 하는데, 기존 소스가 php 파일임에도 불구하고 html 확장자로 되어 있어서 초기 셋팅에 애를 먹었었다.
- location / {} 에 fast_cgi 관련 설정을 넣으니 <!DOCTYPE html> 태그가 html 파일에 선언되어 있을 때 css가 작동하지 않았고, 해당 태그를 삭제하니 css가 작동했다.
이 때 fiddler를 통해 좀 더 분석해 보니 css 파일이나 js 파일의 response type이 text/html 로 되어 있는 것이 문제였다. - 그래서 최종적으로는 php,html 확장자에 대해서만 fast_cgi 설정을 넣고, location / {} 의 경우는 기본설정을 유지하는 방향으로 설정하였다.
* nginx.conf 파일 (수정한 부분 위주로)
server {
...
location ~ \.(php|html)$ {
root C:/docRoot/html;
fastcgi_pass 127.0.0.1:9101;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
fastcgi_index index.php;
include fastcgi.conf;
}
location / {
root C:/docRoot/html;
index index.html index.htm;
}
...
}