LimeSurvey nginx örnek yapılandırması
From LimeSurvey Manual
LimeSurvey için Nginx yapılandırma örneği
Aşağıda, LimeSurvey'i nginx ve PHP-FPM ile çalıştırmak için örnek bir yapılandırma bulunmaktadır. Yolları, etki alanı adlarını ve PHP-FPM soket/bağlantı noktası ayarlarını kendi sunucu kurulumunuza göre düzenleyin.
Not: Bu temel bir örnektir. Üretim ortamında kullanmadan önce mutlaka gözden geçirin ve kendi güvenlik gereksinimlerinize göre uyarlayın.
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;
}
}
Temel yönergelerin açıklaması
fastcgi_pass: PHP isteklerini işleyen PHP-FPM soketine veya TCP adresine işaret eder. Bunu PHP-FPM havuzu yapılandırmanıza uyacak şekilde güncelleyin.try_files: URL'lerin LimeSurvey'in ön denetleyicisi (index.php) üzerinden doğru şekilde yönlendirilmesini sağlar.client_max_body_size: Azami yükleme boyutunu artırır; dosya yükleme sorusu içeren anketler için yararlıdır.- Deny rules: Yapılandırma dosyalarına, günlüklere ve herkese açık olmaması gereken uygulama dizinlerine doğrudan web erişimini engeller. nginx, kurallı ifade konumlarını göründükleri sırayla kontrol eder ve ilk eşleşme geçerli olur. Engelleme kurallarını PHP konumunun üstünde tutun; aksi takdirde bu dizinlerdeki PHP dosyaları engellenmek yerine çalıştırılır.
- Installation in a subdirectory: Örnek, LimeSurvey'in belge kök dizinine kurulduğunu varsayar. LimeSurvey'i bir alt dizine kurarsanız, alt dizini engelleme kurallarının yollarına ekleyin; örneğin
location ^~ /limesurvey/vendor/.