LimeSurvey nginx 구성 예시
From LimeSurvey Manual
LimeSurvey용 Nginx 구성 예시
다음은 nginx와 PHP-FPM으로 LimeSurvey를 실행하기 위한 구성 예시입니다. 서버 환경에 맞게 경로, 도메인 이름, PHP-FPM 소켓/포트 설정을 조정하십시오.
참고: 이 예시는 기본적인 구성입니다. 운영 환경에서 사용하기 전에 반드시 검토하고 사용자의 보안 요구 사항에 맞게 수정하십시오.
server {
listen 80;
server_name survey.example.com;
# Redirect all HTTP traffic to HTTPS
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
server_name survey.example.com;
root /var/www/limesurvey;
index index.php;
# SSL certificates
ssl_certificate /etc/ssl/certs/survey.example.com.crt;
ssl_certificate_key /etc/ssl/private/survey.example.com.key;
# Recommended SSL settings
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
client_max_body_size 100M;
access_log /var/log/nginx/limesurvey_access.log;
error_log /var/log/nginx/limesurvey_error.log;
location / {
index index.html index.php;
try_files $uri $uri/ /index.php?$args;
}
# Deny access to directories that are only used on the server
# ^~ gives these locations priority over the PHP location below, so PHP files in them are never executed
location ^~ /application/ { deny all; }
location ^~ /vendor/ { deny all; }
location ^~ /docs/ { deny all; }
location ^~ /locale/ { deny all; }
location ^~ /modules/ { deny all; }
location ^~ /tmp/runtime/ { deny all; }
location ^~ /tests/ { deny all; }
# Uploaded files: never execute scripts, never deliver files uploaded by participants directly
location ^~ /upload/ {
location ~* \.(php\d?|phtml|pl|py|pyc|pyo|cgi|pcgi\d?|sh|lua|icn)$ {
deny all;
}
location ~ ^/upload/surveys/.*/fu_[a-z0-9_]*$ {
deny all;
}
try_files $uri =404;
}
# Regular expression locations are checked in order and the first match wins,
# so all deny rules below must stay above the PHP location
# Deny access to hidden files and directories, except .well-known
location ~ /\.(?!well-known) {
deny all;
}
# Deny access to the internal directories of the KCFinder file manager
location ~ ^/assets/packages/kcfinder/(conf|core|doc|integration|lang|lib|tpl)/ {
deny all;
}
# Deny access to development, build and debug files in the LimeSurvey root directory
location ~ ^/(setdebug\.php|open-api-gen\.php|composer\.(json|lock)|package\.json|yarn\.lock|gulpfile\.js|phpunit\.xml|psalm(-\w+)?\.xml|phpci\.yml|phpcs\.ruleset\.xml|publiccode\.yml|manifest\.yml|CONTRIBUTING\.md|README\.md|SECURITY\.md)$ {
deny all;
}
location ~* \.(log|sql|htaccess)$ {
deny all;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/run/php/php8.1-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
주요 지시어 설명
fastcgi_pass: PHP 요청을 처리하는 PHP-FPM 소켓 또는 TCP 주소를 지정합니다. 사용 중인 PHP-FPM 풀 구성에 맞게 수정하십시오.try_files: URL이 LimeSurvey의 프런트 컨트롤러(index.php)를 통해 올바르게 라우팅되도록 합니다.client_max_body_size: 최대 업로드 크기를 늘립니다. 파일 업로드 질문이 포함된 설문조사에 유용합니다.- 거부 규칙(Deny rules): 구성 파일, 로그, 애플리케이션 디렉터리 등 외부에 공개되어서는 안 되는 항목에 대한 직접적인 웹 접근을 차단합니다. nginx는 정규표현식 location을 나타나는 순서대로 확인하며, 가장 먼저 일치하는 규칙이 적용됩니다. 거부 규칙은 PHP location보다 위에 두십시오. 그렇지 않으면 이러한 디렉터리의 PHP 파일이 거부되지 않고 실행됩니다.
- 하위 디렉터리에 설치: 이 예제는 LimeSurvey가 문서 루트에 설치되어 있다고 가정합니다. 하위 디렉터리에 설치한 경우 거부 규칙의 경로에 해당 하위 디렉터리를 추가하십시오. 예:
location ^~ /limesurvey/vendor/.