Sponsor:

Server and Web Integrator
Link:
Kloxo-MR logo
6.5.0 or 7.0.0
Click for "How to install"
Donation/Sponsorship:
Kloxo-MR is open-source.
Donate and or Sponsorship always welcome.
Click to:
Click Here
Please login or register. 2024-04-28, 15:13:12

Author Topic: Configure clean URLs with Nginx (Drupal 7)  (Read 7863 times)

0 Members and 1 Guest are viewing this topic.

Offline hoangsang

  • Valuable Member
  • *
  • Posts: 97
  • Karma: +0/-0
    • View Profile
Configure clean URLs with Nginx (Drupal 7)
« on: 2014-03-06, 01:26:29 »
My system:
Code: [Select]
A. Kloxo-MR: 6.5.0.f-2014020201

B. OS: CentOS release 5.8 (Final) x86_64

C. Apps:
   1. MySQL: mysql55-5.5.36-1.ius.el5
   2. PHP: php53u-5.3.28-1.ius.el5
   3. Httpd: --uninstalled--
   4. Lighttpd: --uninstalled--
   5. Nginx: nginx-1.5.10-1.el5
   6. Qmail: qmail-toaster-1.03-1.3.35.mr.el5
      - with: courier-imap-toaster-4.1.2-1.3.14.mr.el5
   7. Dns: bind-9.9.5-1.el5

I installed drupal 7 to directory 'reader' in my domain; and my drupal site is: mydomain.com/reader.
And how to configure clean URLs in Nginx?
Thanks!

Offline MRatWork

  • Administrator
  • The Elite
  • *****
  • Posts: 15,807
  • Karma: +119/-11
  • Gender: Male
    • View Profile
    • MRatWork Forum
Re: Configure clean URLs with Nginx (Drupal 7)
« Reply #1 on: 2014-03-06, 05:57:16 »
What you mean 'Clean URL'?. Is it mean 'permalink URL'?.
..:: MRatWork (Mustafa Ramadhan Projects) ::..
-- Server/Web-integrator - Web Hosting (Kloxo-MR READY!) --

Offline hoangsang

  • Valuable Member
  • *
  • Posts: 97
  • Karma: +0/-0
    • View Profile
Re: Configure clean URLs with Nginx (Drupal 7)
« Reply #2 on: 2014-03-06, 06:43:40 »
Yes. I config like link: https://drupal.org/node/976392
But it not work.

Offline MRatWork

  • Administrator
  • The Elite
  • *****
  • Posts: 15,807
  • Karma: +119/-11
  • Gender: Male
    • View Profile
    • MRatWork Forum
Re: Configure clean URLs with Nginx (Drupal 7)
« Reply #3 on: 2014-03-06, 07:41:49 »
Inform here what's your custom nginx config.
..:: MRatWork (Mustafa Ramadhan Projects) ::..
-- Server/Web-integrator - Web Hosting (Kloxo-MR READY!) --

Offline hoangsang

  • Valuable Member
  • *
  • Posts: 97
  • Karma: +0/-0
    • View Profile
Re: Configure clean URLs with Nginx (Drupal 7)
« Reply #4 on: 2014-03-06, 07:59:15 »
File config: mydomain.com.conf
Code: [Select]
### begin - web of 'mydomain.com' - do not remove/modify this line


## web for 'mydomain.com'
server {
    listen 0.0.0.0:80;
    listen [::]:80;

    server_name mydomain.com www.mydomain.com;

    index index.php index.html index.shtml index.htm default.htm Default.aspx Default.asp index.pl;

    set $domain 'mydomain.com';

    set $rootdir '/home/userdomain/mydomain.com';

    root $rootdir;

    set $user 'userdomain';


    ## Add clean URLs 05-03-2014
    # location / {
    #    root   /reader;
    #     index  index.php;
    #     error_page 404 = @reader;
    # }

      location @reader {
         rewrite ^(.*)$ /index.php?q=$1 last;
      }

    ## The end


    access_log /home/httpd/mydomain.com/stats/mydomain.com-custom_log main;
    error_log  /home/httpd/mydomain.com/stats/mydomain.com-error_log;

    set $statstype 'awstats';

    include '/home/nginx/conf/globals/awstats.conf';

    set $fpmport '51011';

    include '/home/nginx/conf/globals/php-fpm.conf';

    include '/home/nginx/conf/globals/perl.conf';

    include '/home/nginx/conf/globals/generic.conf';
}


## webmail for 'mydomain.com' handled by ../webmails/webmail.conf


## web for 'mydomain.com'
server {
    listen 0.0.0.0:443;
    listen [::]:443;

    ssl on;
    ssl_certificate /home/kloxo/httpd/ssl/eth0___localhost.crt;
    ssl_certificate_key /home/kloxo/httpd/ssl/eth0___localhost.key;
    ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers HIGH:!aNULL:!MD5;

    server_name mydomain.com www.mydomain.com;

    index index.php index.html index.shtml index.htm default.htm Default.aspx Default.asp index.pl;

    set $domain 'mydomain.com';

    set $rootdir '/home/userdomain/mydomain.com';

    root $rootdir;

    set $user 'userdomain';

    access_log /home/httpd/mydomain.com/stats/mydomain.com-custom_log main;
    error_log  /home/httpd/mydomain.com/stats/mydomain.com-error_log;

    set $statstype 'awstats';

    include '/home/nginx/conf/globals/awstats.conf';

    set $fpmport '51011';

    include '/home/nginx/conf/globals/php-fpm.conf';

    include '/home/nginx/conf/globals/perl.conf';

    include '/home/nginx/conf/globals/generic.conf';
}


## webmail for 'mydomain.com' handled by ../webmails/webmail.conf


### end - web of 'mydomain.com' - do not remove/modify this line



Offline MRatWork

  • Administrator
  • The Elite
  • *****
  • Posts: 15,807
  • Karma: +119/-11
  • Gender: Male
    • View Profile
    • MRatWork Forum
Re: Configure clean URLs with Nginx (Drupal 7)
« Reply #5 on: 2014-03-06, 08:15:59 »
If you see /home/nginx/conf/globals.conf and you will find:

Code: [Select]
    location / {
        limit_conn addr 25;

        try_files $uri $uri/ /index.php;
    }

Where have 2 options:

1. ' limit_conn addr 25' for DDOS protect
2. 'try_files $uri $uri/ /index.php' for generic permalink

So you can copy php-fpm.conf to custom.php-fpm.conf and then modified this custom file related to your need.

Run 'sh /script/fixweb; sh /script/restart-web' after modification.

That it.
..:: MRatWork (Mustafa Ramadhan Projects) ::..
-- Server/Web-integrator - Web Hosting (Kloxo-MR READY!) --

Offline hoangsang

  • Valuable Member
  • *
  • Posts: 97
  • Karma: +0/-0
    • View Profile
Re: Configure clean URLs with Nginx (Drupal 7)
« Reply #6 on: 2014-03-06, 09:39:15 »
Code: [Select]
    location / {
        limit_conn addr 25;

        try_files $uri $uri/ /index.php;
    }
I find at '/home/nginx/conf/globals/php-fpm.conf'. But I do not know how to fix it right. And my server runs multiple websites at once.
Please help me!

Offline zenkul

  • Global Moderator
  • Master
  • *****
  • Posts: 383
  • Karma: +3/-0
    • View Profile
    • home & decor
Re: Configure clean URLs with Nginx (Drupal 7)
« Reply #7 on: 2014-03-06, 11:44:53 »
Clean URL = Permalink URL

 it's built in at kloxo-mr as "generic permalink" which can work on all types of web servers, include drupal clean urls in 'nginx'

so no need to configure it, because automatic work


.......
BTW : I suggest, choose 'nginx-proxy'
easy, secure and speed up web panel ===> Kloxo-MR

Offline MRatWork

  • Administrator
  • The Elite
  • *****
  • Posts: 15,807
  • Karma: +119/-11
  • Gender: Male
    • View Profile
    • MRatWork Forum
Re: Configure clean URLs with Nginx (Drupal 7)
« Reply #8 on: 2014-03-06, 12:31:45 »
@zenkul,

Look like:
Code: [Select]
    location / {
        limit_conn addr 25;

        error_page 404 = @permalink;
    }

    location @permalink {
        try_files $uri $uri/ /index.php;
    }

is better than:
Code: [Select]
    location / {
        limit_conn addr 25;

        try_files $uri $uri/ /index.php;
    }

In original code, all request will be 'transfer' to /index.php (I think, it's may problem with '/wp-admin' in wordpress).

In modified code, only 'no exist file' will be 'transfer' to /index.php.

Can you helping me to test above code?.

..:: MRatWork (Mustafa Ramadhan Projects) ::..
-- Server/Web-integrator - Web Hosting (Kloxo-MR READY!) --

Offline hoangsang

  • Valuable Member
  • *
  • Posts: 97
  • Karma: +0/-0
    • View Profile
Re: Configure clean URLs with Nginx (Drupal 7)
« Reply #9 on: 2014-03-06, 12:43:13 »
Use URLs like example.com/user instead of example.com/?q=user.
If no need to configure it, the clean URL test failed (Drupal 7).
« Last Edit: 2014-03-06, 12:49:12 by hoangsang »

Offline zenkul

  • Global Moderator
  • Master
  • *****
  • Posts: 383
  • Karma: +3/-0
    • View Profile
    • home & decor
Re: Configure clean URLs with Nginx (Drupal 7)
« Reply #10 on: 2014-03-06, 17:30:07 »
sorry, not work at all

result at the new code : 403 Forbidden nginx/1.5.11
easy, secure and speed up web panel ===> Kloxo-MR

Offline MRatWork

  • Administrator
  • The Elite
  • *****
  • Posts: 15,807
  • Karma: +119/-11
  • Gender: Male
    • View Profile
    • MRatWork Forum
Re: Configure clean URLs with Nginx (Drupal 7)
« Reply #11 on: 2014-03-07, 04:34:23 »
Yes, not work. In original code look like missing css/js.

I found hiawatha (in Kloxo-MR 6.5.1) work perfectly for wordpress. I am not testing for drupal.
..:: MRatWork (Mustafa Ramadhan Projects) ::..
-- Server/Web-integrator - Web Hosting (Kloxo-MR READY!) --

Offline MRatWork

  • Administrator
  • The Elite
  • *****
  • Posts: 15,807
  • Karma: +119/-11
  • Gender: Male
    • View Profile
    • MRatWork Forum
Re: Configure clean URLs with Nginx (Drupal 7)
« Reply #12 on: 2014-03-07, 05:05:51 »
Hiawatha also work for Drupal 7 without modified hiawatha config.

See http://test.next.potissima.com for drupal and http://next.potissima.com for wordpress.
..:: MRatWork (Mustafa Ramadhan Projects) ::..
-- Server/Web-integrator - Web Hosting (Kloxo-MR READY!) --

Offline zenkul

  • Global Moderator
  • Master
  • *****
  • Posts: 383
  • Karma: +3/-0
    • View Profile
    • home & decor
Re: Configure clean URLs with Nginx (Drupal 7)
« Reply #13 on: 2014-03-07, 08:51:54 »
yes, hiawatha is fully compatible with drupal 7
easy, secure and speed up web panel ===> Kloxo-MR

Offline zenkul

  • Global Moderator
  • Master
  • *****
  • Posts: 383
  • Karma: +3/-0
    • View Profile
    • home & decor
Re: Configure clean URLs with Nginx (Drupal 7)
« Reply #14 on: 2014-03-07, 11:29:22 »
@hoangsang
I try drupal 7 in 'nginx-proxy'
there is built-in 'microcache'

with drupal modul : 'cache warmer' for trouble handling caused nginx cache
also 'Nginx Accel Redirect' for fast and protection private file
etc

..............
my opinion : using "Nginx only" is very painful, too many uncompatibility with my D7 site, like 'bomb character' and clean url as the last trouble. *note ( I am is common user )
easy, secure and speed up web panel ===> Kloxo-MR

 


MRatWork Affiliates:    BIGRAF(R) Inc.    House of LMAR    EFARgrafix
Click Here

Page created in 0.071 seconds with 21 queries.

web stats analysis