x

主要章節

  1. LimeSurvey Cloud 與 LimeSurvey CE 的差異
  2. 快速入門指南 - LimeSurvey 3.0+
  3. 安裝 - LimeSurvey CE
  4. 如何設計一份好的問卷(指南)
  5. 入門指南
  6. 管理 LimeSurvey
  7. 問卷 - 簡介
  8. 問卷設定
  9. 問卷選單
  10. 問卷結構
  11. 問題簡介
  12. 題組 - 簡介
  13. 問卷管理
  14. 問卷工具列選項
  15. 多語言問卷
  16. ExpressionScript 引擎 - 快速入門指南
  17. 未分類及進階功能
  18. 常見問題
  19. 疑難排解
  20. 應變方案
  21. 授權條款
  22. 版本更改紀錄檔
  23. 外掛程式
 Actions

LimeSurvey nginx 設定範例

From LimeSurvey Manual

本頁面可能為機器翻譯,可能包含錯誤。 檢視英文原文 · 改善此翻譯
This page is a translated version of the page LimeSurvey nginx example configuration and the translation is 100% complete.

LimeSurvey 的 Nginx 設定範例

以下是使用 nginx 和 PHP-FPM 執行 LimeSurvey 的設定範例。請根據您的伺服器環境調整路徑、網域名稱以及 PHP-FPM 的 socket/連接埠設定。

注意: 這只是一個基本範例。在正式環境中使用之前,請務必根據您自己的安全需求進行檢查和調整。

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;
    }

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;
    }

# Deny access to hidden files and sensitive directories
    location ~ /\.(?!well-known).* {
        deny all;
    }

location ~ ^/tmp/runtime/ {
        deny  all;
    }
location ~* /(application|protected|modules|locale|framework|vendor|tests|docs|db|application/config)/ {
        deny all;
    }

# Disallow uploaded potential executable files in upload directory
location ~* /upload/.*\.(pl|cgi|py|pyc|pyo|phtml|sh|lua|php|php3|php4|php5|php6|pcgi|pcgi3|pcgi4|pcgi5|pcgi6|icn)$ {
        return 444;
    }

#Disallow direct read user upload files
location ~ ^/upload/surveys/.*/fu_[a-z0-9]*$ {
        return 444;
    }

location ~* \.(log|sql|htaccess)$ {
        deny all;
    }

# Allow LimeSurvey to serve uploaded files and assets
    location /upload/ {
        try_files $uri $uri/ =404;
    }
}

主要指令說明

  • fastcgi_pass:指向處理 PHP 請求的 PHP-FPM socket 或 TCP 位址。請依據您的 PHP-FPM pool 設定進行更新。
  • try_files:確保 URL 能透過 LimeSurvey 的前端控制器(index.php)正確路由。
  • client_max_body_size:提高上傳的最大值,適用於包含檔案上傳題型的問卷。
  • 拒絕規則:阻擋對設定檔、日誌和不應公開存取的應用程式目錄的直接網頁存取。