nginx rewrite for drupal

Discussion in 'Installation/Configuration' started by icphedia, Apr 26, 2012.

  1. icphedia

    icphedia New Member

    hi,

    i installed ispconfig3 nginx on centos 6.2

    everything works fine except drupal 7 clean urls.

    i tried some directives on ispconfig nginx Directives settings but wont work.

    any suggestions?
     
  2. falko

    falko Super Moderator Howtoforge Staff

    Try this in the nginx Directives field on the Options tab:

    Code:
           # Make sure files with the following extensions do not get loaded by nginx because nginx would display the source code, and these files can contain PASSWORDS!
            location ~* \.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(\..*|Entries.*|Repository|Root|Tag|Template)$|\.php_ {
                    deny all;
            }
    
           location / {
                    if ($query_string ~ ".+") {
                            return 405;
                    }
                    # pass requests from logged-in users to Apache
                    if ($http_cookie ~ "DRUPAL_UID" ) {
                            return 405;
                    } # pass POST requests to Apache
                    if ($request_method !~ ^(GET|HEAD)$ ) {
                            return 405;
                    }
                    error_page 405 = @nocache;
                    # do not allow browsers to cache HTML
                    add_header Expires "Sun, 19 Nov 1978 05:00:00 GMT";
                    add_header Cache-Control "no-store, no-cache, must-revalidate, post-check=0, pre-check=0";
                    # serve requested content from the cache if available, otherwise pass the request to Apache
                    try_files /cache/normal/$host/${uri}_.html /cache/perm/$host/${uri}_.css /cache/perm/$host/${uri}_.js /cache/$host/0$uri.html /cache/$host/0${uri}/index.html @nocache;
           }
    
           location @nocache {
                    try_files $uri $uri/ /index.php?$args;
           }
    
           location ~*  \.(jpg|jpeg|png|gif|css|js|ico)$ {
                    expires max;
                    log_not_found off;
           }
    (This configuration is for use with Drupal's Boost module.)

    The configuration is based on this tutorial: http://www.howtoforge.com/running-drupal-7.7-on-nginx-lemp-on-debian-squeeze-ubuntu-11.04
     
  3. icphedia

    icphedia New Member

    thanx falko but it didnt work.

    sites working with apache again..
     
  4. sistematico

    sistematico New Member

  5. Croydon

    Croydon ISPConfig Developer ISPConfig Developer

    Isn't it quite obvious? There is a link given on each of these warning rows. Just follow it and follow the instructions there ;)
     
  6. sistematico

    sistematico New Member

    No, is not obvious.
    Im using Nginx, this instructions is for Apache.
     
  7. Croydon

    Croydon ISPConfig Developer ISPConfig Developer

    You can rewrite nearly all htaccess rewrite or deny/allow directives to nginx.
    If you don't know how, maybe this would be a first step:
    http://winginx.com/htaccess
     

Share This Page