无法再将图像上传到Redmine

时间:2014-12-03 18:12:17

标签: ruby redmine

由于某些奇怪的原因,我无法将图像上传到Redmine的门票。我可以上传一个txt文件或zip文件。当我在票证中上传图像时,它会显示“服务不可用”或“不可处理”。奇怪的是它曾经工作过。我们更新到最新的Redmine(2.6.0.stable)

我查看了production.log,这是错误(无法验证CSRF令牌真实性):

Started POST "/uploads.js?attachment_id=1&filename=test.png" for xx.xx.xxx.xxx at 2014-12-03 12:58:49 -0500
Processing by AttachmentsController#upload as JS
Parameters: {"attachment_id"=>"1", "filename"=>"test.png"}
WARNING: Can't verify CSRF token authenticity
Filter chain halted as :verify_authenticity_token rendered or redirected
Completed 422 Unprocessable Entity in 2.6ms (ActiveRecord: 0.3ms)

这是我的Redmine信息:

Default administrator account changed	   True
Attachments directory writable	           True
Plugin assets directory writable	   True
RMagick available (optional)               Exclamation
ImageMagick convert available (optional)   True

Environment:
  Redmine version                2.6.0.stable
  Ruby version                   1.9.3-p547 (2014-05-14) [x86_64-linux]
  Rails version                  3.2.19
  Environment                    production
  Database adapter               Mysql2
SCM:
  Git                            1.8.2.1
  Filesystem                     
Redmine plugins:
  redmine_agile                  1.3.2
  redmine_ckeditor               1.0.16
  redmine_github_hook            2.1.0
  redmine_my_page_queries        2.1.6
  redmine_theme_changer          0.1.0

1 个答案:

答案 0 :(得分:1)

事实证明这是一个清漆问题。我们通过添加此Varnish规则解决了这个问题:

if (req.http.host ~ "my\.domain\.com$") {
   return (pipe);
}

以下是我们为解决问题所做的一些调试工作。

  1. 暂时将config.action_controller.allow_forgery_protection = false添加到application.rb。当我们尝试上传图片时,我得到了一个Popup:Redmine API上的Server需要登录。这给了我一个线索,它一定是某种服务器问题。

  2. 创建了additional_environment.rb并启用了config.log_level =:debug。这为日志文件添加了更多调试信息。

  3. Started POST "/uploads.js?attachment_id=1&filename=Screen%20Shot%202014-12-11%20at%2010.01.49%20AM.png" for xx.xx.xxx.xxx at 2014-12-11 11:07:41 -0500
    Processing by AttachmentsController#upload as JS
      Parameters: {"attachment_id"=>"1", "filename"=>"Screen Shot 2014-12-11 at 10.01.49 AM.png"}
      ^[[1m^[[35m (0.3ms)^[[0m  SELECT MAX(`settings`.`updated_on`) AS max_id FROM `settings`
      ^[[1m^[[36mSetting Load (0.3ms)^[[0m  ^[[1mSELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'rest_api_enabled' LIMIT 1^[[0m
      ^[[1m^[[35mAnonymousUser Load (0.3ms)^[[0m  SELECT `users`.* FROM `users` WHERE `users`.`type` IN ('AnonymousUser') LIMIT 1
      Current user: anonymous
      ^[[1m^[[36mSetting Load (0.3ms)^[[0m  ^[[1mSELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'login_required' LIMIT 1^[[0m
      ^[[1m^[[35mSetting Load (0.2ms)^[[0m  SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'force_default_language_for_anonymous' LIMIT 1
      ^[[1m^[[36mSQL (1.2ms)^[[0m  ^[[1mSELECT `members`.`id` AS t0_r0, `members`.`user_id` AS t0_r1, `members`.`project_id` AS t0_r2, `members`.`created_on` AS t0_r3, `members`.`mail_notification` AS t0_r4, `projects`.`id` AS t1_r0, `projects`.`name` AS t1_r1, `projects`.`description` AS t1_r2, `projects`.`homepage` AS t1_r3, `projects`.`is_public` AS t1_r4, `projects`.`parent_id` AS t1_r5, `projects`.`created_on` AS t1_r6, `projects`.`updated_on` AS t1_r7, `projects`.`identifier` AS t1_r8, `projects`.`status` AS t1_r9, `projects`.`lft` AS t1_r10, `projects`.`rgt` AS t1_r11, `projects`.`inherit_members` AS t1_r12, `roles`.`id` AS t2_r0, `roles`.`name` AS t2_r1, `roles`.`position` AS t2_r2, `roles`.`assignable` AS t2_r3, `roles`.`builtin` AS t2_r4, `roles`.`permissions` AS t2_r5, `roles`.`issues_visibility` AS t2_r6 FROM `members` LEFT OUTER JOIN `projects` ON `projects`.`id` = `members`.`project_id` LEFT OUTER JOIN `member_roles` ON `member_roles`.`member_id` = `members`.`id` LEFT OUTER JOIN `roles` ON `roles`.`id` = `member_roles`.`role_id` WHERE `members`.`user_id` = 2 AND (projects.status<>9) ORDER BY projects.name^[[0m
      ^[[1m^[[35mRole Load (0.2ms)^[[0m  SELECT `roles`.* FROM `roles` WHERE `roles`.`builtin` = 2 LIMIT 1
    Filter chain halted as :authorize_global rendered or redirected
    Completed 401 Unauthorized in 54.3ms (ActiveRecord: 2.7ms)

    当前用户:日志类型中的匿名帮助导致修复。