Project

General

Profile

Bug #7926

Non-working nginx rewrite rule with multiple params

Added by David Auzeine about 4 years ago. Updated almost 4 years ago.

Status:
Bug resolved
Priority:
Normal
Category:
System
Target version:
Start date:
31/10/2015
Due date:
% Done:

100%

Estimated time:
Spent time:
Complexity:
Normal
SCRUM pts - complexity:
?

Description

In the installation guide (both in english and spanish), there's a line with 2 parameters:

rewrite ^/badge/(\d{1,})/user/(\d{1,})$ main/badge/issued.php?skill=$1&user=$2 last;

There must be double quotes enclosing the first part of the expression:

rewrite "^/badge/(\d{1,})/user/(\d{1,})$" main/badge/issued.php?skill=$1&user=$2 last;


Files

lms.conf (2.74 KB) lms.conf ashish kpaul, 27/12/2015 08:41
lms-v-1.conf (2.84 KB) lms-v-1.conf ashish kpaul, 07/01/2016 05:14

Related issues

Related to Chamilo LMS - Bug #8035: Nginx static files config for showing html in framesBug resolved06/01/2016

Actions

Associated revisions

Revision 150bd15d (diff)
Added by Yannick Warnier almost 4 years ago

Fix Nginx config example - refs #7926

Revision e5a590eb (diff)
Added by Yannick Warnier almost 4 years ago

Fix Nginx config example - refs #7926

History

#1

Updated by Yannick Warnier about 4 years ago

  • Category set to System
  • Status changed from New to Needs more info
  • Assignee set to David Auzeine
  • Target version set to 1.10.2
  • % Done changed from 0 to 10

That's strange, it worked fine for me. What operating system are you running Nginx on, and what version of Nginx?
I tested it on Ubuntu 15.04 and Nginx 1.6.2

#2

Updated by Yannick Warnier about 4 years ago

This suggests that other Nginx rules should also include the double quotes (")...

#3

Updated by David Auzeine about 4 years ago

My config: Ubuntu Server LTS 14.04 and nginx 1.8.0 (used as frontend for Apache2.4.16)
I think this is the only rule that needs the double quotes, 'cause this is the only rule with two params (found the answer in Stackoverflow, don't remember the post...).

When I don't insert the double quotes, I test my nginx config with: nginx -t
And then :
nginx: [emerg] directive "rewrite" is not terminated by ";" in /etc/nginx/sites-enabled/chamilo:48
nginx: configuration file /etc/nginx/nginx.conf test failed

The line 48 for me is the line with this very rule. There's the ";". But I think it's not the pb: nginx wait for ";" after the first part of the expression (because of the use of 2 params).
So the only issue for me was to input these double quotes...

#4

Updated by Yannick Warnier about 4 years ago

  • Tracker changed from Support to Bug
  • Status changed from Needs more info to Bug resolved
  • % Done changed from 10 to 100

My bad, it looks like you're right. No sure how I missed that.
I just sent a commit to fix this in the documentation. Thanks!

#5

Updated by ashish kpaul almost 4 years ago

Hello sir, Everything running fine except reporting link and course description link, when i clicked on it they redirect to home page and the address-bar url's are http://lms.localhostsaa9vi.lan/main/mySpace/ and http://lms.localhostsaa9vi.lan/main/course_description/?cidReq=INNOVATION&id_session=0&gidReq=0&gradebook=0&origin= respectively. nginx config file is attached And it would be grate if chamilo plugins could be configured respectively to multi-url site like wordpress plugins do work in wordpress multisite .

#6

Updated by ashish kpaul almost 4 years ago

screencast of the prob. https://youtu.be/NpM3FmZZmxw

#7

Updated by Yannick Warnier almost 4 years ago

  • Status changed from Bug resolved to Needs testing
  • Assignee deleted (David Auzeine)
  • Target version changed from 1.10.2 to 1.10.4
  • % Done changed from 100 to 80

Chamilo can be configured in multi-portal with the option multiple_access_urls set to true in app/config/configuration.php:

$_configuration['multiple_access_urls']                                 = true;

Then you have one more item on your main/admin/index.php page.

We will look into the Nginx problem in a little while. Thanks for reporting.

#8

Updated by ashish kpaul almost 4 years ago

Thanks for reply, I test chamilo in multi-url functions but the issue is when i enable and configure bigbluebutton plugin it enables in all multi-url sites as it should be enable and configured in particular multi-url site. suppose in an academy their are two virtual campus(math.org(master chamilo portal) & chem.org(multi-url chamilo portal)), then how to enable and configure two bbb servers(with different urls & salt) respectively with their virtual campus i.e math.org and chem.org.

#9

Updated by ashish kpaul almost 4 years ago

Hello Sir its working for me with little changes ====
server {
listen 80;
server_name lms.localhostsaa9vi.lan;
access_log /var/log/nginx/access_lms-localhostsaa9vi.lan.log;
error_log /var/log/nginx/error_lms-localhostsaa9vi.lan.log notice;
index index.php;
root /var/www/saa9vi_html/lms-saa9vi-1.10.2;

  1. Now include our shared config files
    charset utf-8;

location @rewrite{
rewrite /courses/([/]+)/scorm/(.*)$ /main/document/download_scorm.php?doc_url=/$2&cDir=$1 last;
rewrite /courses/([/]+)/document/(.*)$ /main/document/download.php?doc_url=/$2&cDir=$1 last;
rewrite /courses/([/]+)/work/(.*)$ /main/work/download.php?file=work/$2&cDir=$1 last;
rewrite /courses/([/]+)/upload/(.*)$ /app/courses/$1/upload/$2 last;
try_files $uri /index.php;
break;
}

location / {
rewrite /courses/([/]+)/$ /main/course_home/course_home.php?cDir=$1 last;
rewrite /courses/([/]+)/index.php$ main/course_home/course_home.php?cDir=$1 last;
rewrite ^/main/admin/$ /main/admin/index.php last;
  1. try_files $uri @rewrite; ## just remove this ##
    }
  1. ESSENTIAL : Configure 404 Pages
    error_page 404 /404.html;
  2. ESSENTIAL : Configure 50x Pages
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
    root /usr/share/nginx/www;
    }

    location ~ \.php$ {
    client_max_body_size 20M;
    try_files $uri /index.php$is_args$args;

    rewrite /certificates/$ /certificates/index.php?id=%1  last;
    rewrite ^/courses/([
    /]+)/$ /main/course_home/course_home.php?cDir=$1 last;
    rewrite /courses/([/]+)/index.php$ /main/course_home/course_home.php?cDir=$1 last;
    rewrite /session/([/]+)/about/?$ /main/session/about.php?session_id=$1 last;
    rewrite "^/badge/(\d{1,})/user/(\d{1,})$" main/badge/issued.php?skill=$1&user=$2 last;
    fastcgi_pass    127.0.0.1:9000;
    fastcgi_split_path_info ^(.+\.php)(/.*)$;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param HTTPS off;
    }
    1. Serve static files directly
    1. location * \.(png|jpe?g|gif|ico)$ { ## error : there is ? in jpeg ##
      location ~* \.(png|jpeg|gif|ico|html)$ { ##it will work ##
      expires 1y;
      access_log off;
      rewrite /courses/([/]+)/course-pic85x85.png$ /app/courses/$1/course-pic85x85.png last;
      rewrite /courses/([/]+)/course-pic.png$ /app/courses/$1/course-pic.png last;
      rewrite /courses/([/]+)/scorm/(.*)$ /main/document/download_scorm.php?doc_url=/$2&cDir=$1 last;
      rewrite /courses/([/]+)/document/(.*)$ /main/document/download.php?doc_url=/$2&cDir=$1 last;
      rewrite /courses/([/]+)/work/(.*)$ /main/work/download.php?file=work/$2&cDir=$1 last;
      rewrite /courses/([/]+)/upload/(.*)$ /app/courses/$1/upload/$2 last;
      try_files $uri @rewrite;
      }
      location ~ ~\.(ht|git){
      deny all;
      }
      location ^
      /tests/ {
      deny all;
      }
      }
#10

Updated by ashish kpaul almost 4 years ago

see in attachment this nginx config file work fine

#11

Updated by Yannick Warnier almost 4 years ago

  • Assignee set to Yannick Warnier
#12

Updated by Yannick Warnier almost 4 years ago

Removing the try_files at the end of the "location /" block effectively removes the problem of redirection from course description, but I'm still having issues with opening documents (main/document/showinframes.php). Looking into this now.

#13

Updated by Yannick Warnier almost 4 years ago

I sent new templates in the documentation for the Nginx configuration.
Now I got course description and file download to work.

#14

Updated by Yannick Warnier almost 4 years ago

  • Status changed from Needs testing to Bug resolved
  • % Done changed from 80 to 100

Also available in: Atom PDF