x

主要章节

  1. LimeSurvey Cloud 与 LimeSurvey CE 对比
  2. 快速入门指南 - LimeSurvey 3.0+
  3. 软件安装
  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 的套接字/端口设置。

注意: 这只是一个基础示例。在生产环境中使用之前,请务必根据您自己的安全要求进行检查和调整。

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 套接字或 TCP 地址。请根据您的 PHP-FPM 进程池配置进行更新。
  • try_files:确保 URL 通过 LimeSurvey 的前端控制器(index.php)正确路由。
  • client_max_body_size:提高最大上传大小,适用于包含文件上传问题的调查问卷。
  • 拒绝规则:阻止通过网络直接访问配置文件、日志以及不应公开访问的应用程序目录。