Are these rules ok?

Shri @ DevLib.Org shri at devlib.org
Fri Dec 26 16:10:06 MSK 2008


After a bit of playing around. I think I have a config that works. (Not sure 
I understand some bits, but it does seem to work across all the various 
sections of the site).

I now have to port over dozens of rewrites I assume the best way to do this 
is to put them in a seperate file and include them under "location /" block?

E.g: #RewriteRule ^hong-kong/(.*)$ http://www.geoexpat.com/resources/ 
[R=permanent,L]

Once that is done, need to figure out the

Thanks!

Shri


    server {

        listen  80;
        server_name geoexpat.com www.geoexpat.com;

        root /site/expat/oct08;

        index index.php index.html index.htm;

        location / {
                try_files      $uri  @wordpress;
        }


        location ~ \.php$ {
                try_files      $uri  @wordpress;

                set $script $uri;
                set $path_info "";

                if ($uri ~ "^(.+\.php)(/.+)") {
                        set $script $1;
                        set $path_info $2;
                }

                fastcgi_param  SCRIPT_FILENAME 
/site/expat/oct08$fastcgi_script_name;
                fastcgi_pass   unix:/var/tmp/lighttpd/fastcgi-php.sock;
        #       fastcgi_param  PATH_INFO    $path_info;
                include        fastcgi_params;
        }

        location @wordpress {
                fastcgi_param  SCRIPT_FILENAME  /site/expat/oct08/index.php;
                fastcgi_pass   unix:/var/tmp/lighttpd/fastcgi-php.sock;
                fastcgi_param  PATH_INFO    $path_info;
                include        fastcgi_params;
        }

        location ~* \.(jpg|jpeg|gif|css|png|js|ico)$ {
                access_log      off;
                expires         30d;
                break;
        }

        location /classifieds/ {
                try_files      $uri  @wordpress;

                set $script $uri;
                set $path_info "";

                if ($uri ~ "^(.+\.php)(/.+)") {
                        set $script $1;
                        set $path_info $2;
                }

                fastcgi_param  SCRIPT_FILENAME 
/site/expat/oct08$fastcgi_script_name;
                fastcgi_pass   unix:/var/tmp/lighttpd/fastcgi-php.sock;
                fastcgi_param  PATH_INFO    $path_info;
                include        fastcgi_params;
        }

        location ^~ /scripts/ {
              proxy_pass http://cgiserver;
              proxy_set_header X-Real-IP $remote_addr;
              proxy_set_header Host $host;
              proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }

        location ^~ /resources/Detailed/ {
              proxy_pass http://cgiserver;
              proxy_set_header X-Real-IP $remote_addr;
              proxy_set_header Host $host;
              proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }

        location /forum/ {
                rewrite ^/forum/getnew.html$ /forum/search.php?do=getnew 
last;
                rewrite ^/forum/getnew([0-9]+).html$ 
/forum/search.php?do=getnew&f=$1 last;
                rewrite ^/forum/((urllist|sitemap_).*\.(xml|txt)(\.gz)?)$ 
/forum/vbseo_sitemap/vbseo_getsitemap.php?sitemap=$1 last;
                rewrite ^/forum/unanswered.html$ 
/forum/search.php?do=process&replyless=1&replylimit=0&dontcache=1 last;
                rewrite ^/forum/unanswered([0-9]+).html$ 
/forum/search.php?do=process&replyless=1&replylimit=0&dontcache=1&forumchoice=$1&childforums=1 
last;
                try_files      $uri  @vbulletin;
        }

        location ~ ^/forum/.+\.php$ {
                fastcgi_pass   unix:/var/tmp/lighttpd/fastcgi-php.sock;
                fastcgi_param  SCRIPT_FILENAME 
/site/expat/oct08/forum/vbseo.php;
                include        fastcgi_params;
        }

        location @vbulletin {
                fastcgi_pass   unix:/var/tmp/lighttpd/fastcgi-php.sock;
                fastcgi_param  SCRIPT_FILENAME 
/site/expat/oct08/forum/vbseo.php;
                include        fastcgi_params;
        }

        location /jobs/ {
                rewrite ^/jobs/category/(.+)$ /jobs/index.php?cat_name=$1 
last;
                rewrite ^/jobs/job/(.+)$ 
/jobs/index.php?post_permalink=1&post_id=$1  last;
                rewrite ^/jobs/profile/(.+)$ /jobs/index.php?show_emp=$1 
last;
                rewrite ^/jobs/page(.+)$ /jobs/index.php?job_page_link=$1 
last;
        }

        location ~ /\.ht {
            deny  all;
        }
    }







More information about the nginx mailing list