Uncorrupted Blog

Get the inside scoop from us dirrectly from our own blog

OCT6

WHMCS Rewrite Rules for Nginx

by Uncorrupted-Michael

nginx_logo
WHMCS is a very popular client management package with a slew of billing, support, and product management options. We use it here and have just recently moved our WHMCS site over to an nginx powered web server. The rewrites have all been worked out and since there’s nothing to be found on the subject via google we decided to share. :)

server {
            listen   80;
            server_name  my.uncorrupted.net;
            rewrite ^/(.*) https://my.uncorrupted.net/$1 permanent;
       }

server {
            listen   443;
            server_name my.uncorrupted.net;
            access_log /xxx/xxx/xxx/logs/access.log;
            error_log /xxx/xxx/xxx/logs/error.log;
	    	ssl on;
	    	ssl_certificate /xxx/xxx/xxx/.ssl/cert.pem;
	    	ssl_certificate_key /xxx/xxx/xxx/.ssl/key.pem;

            location /  {
                        root   /xxx/xxx/xxx/public_html/;
                        index  index.html index.php;
		    }

			location = /announcements {
        				rewrite ^  /announcements.php  last;
    		}

    		location /announcements/ {
        				rewrite  ^/announcements/([0-9]+)/[A-Za-z0-9_-]+\.html$ /announcements.php?id=$1 last;
    		}

    		location = /downloads {
        				rewrite ^  /downloads.php  last;
    		}

    		location /downloads/ {
        				rewrite ^/downloads/([0-9]+)/([^/]*)$ /downloads.php?action=displaycat&catid=$1 last;
    		}
			location = /knowledgebase {
       					rewrite ^  /knowledgebase.php  last;
    		}
			location /knowledgebase/ {
        				rewrite  ^/knowledgebase/([0-9]+)/[A-Za-z0-9_-]+\.html$ /knowledgebase.php?action=displayarticle&id=$1 last;
        				rewrite  ^/knowledgebase/([0-9]+)/([^/]*)$ /knowledgebase.php?action=displaycat&catid=$1 last;
    		}

            # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
            location ~ \.php$ {
            			fastcgi_pass 127.0.0.1:9000;
            			fastcgi_index index.php;
            			include /usr/local/nginx/conf/fastcgi_params;
            			fastcgi_param SCRIPT_FILENAME /xxx/xxx/xxx/public_html/$fastcgi_script_name;
            }
}

Gest of luck – if you run into any issues write us a comment and we’ll see if we can help you work it out.

Category :Technical Articles
Tags : none

Comments

  • Niels October 26, 2009 @ 8:14 am

    Hi, thanks for sharing, saves me some time. Could you also share your fastcgi_params? Mine may be missing something.

    E.g. my WHMCS links to ?a=view where it should link to cart.php?a-view, etc.

  • Michael.Terence October 26, 2009 @ 8:27 am

    Certainly,

    They’re the standard params included in: /usr/local/nginx/conf/fastcgi_params

    fastcgi_param QUERY_STRING $query_string;
    fastcgi_param REQUEST_METHOD $request_method;
    fastcgi_param CONTENT_TYPE $content_type;
    fastcgi_param CONTENT_LENGTH $content_length;

    fastcgi_param SCRIPT_NAME $fastcgi_script_name;
    fastcgi_param REQUEST_URI $request_uri;
    fastcgi_param DOCUMENT_URI $document_uri;
    fastcgi_param DOCUMENT_ROOT $document_root;
    fastcgi_param SERVER_PROTOCOL $server_protocol;

    fastcgi_param GATEWAY_INTERFACE CGI/1.1;
    fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;

    fastcgi_param REMOTE_ADDR $remote_addr;
    fastcgi_param REMOTE_PORT $remote_port;
    fastcgi_param SERVER_ADDR $server_addr;
    fastcgi_param SERVER_PORT $server_port;
    fastcgi_param SERVER_NAME $server_name;

    # PHP only, required if PHP was built with –enable-force-cgi-redirect
    fastcgi_param REDIRECT_STATUS 200;

  • Niels October 26, 2009 @ 12:25 pm

    Thanks. Unfortunately that’s what I have. Time to dig a little deeper…

Add your own Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Sidebar

Grab Our Button

Uncorrupted Hosting - High Performance Managed VPSs

Testimonials

  • testimonial Amy from Amy Loves it says:

    The assistance Uncorrupted has provided me has been priceless. My website would not be what it is without their service.

  • DealSeekingMom.com Testimonial Tara from Deal Seeking Mom says:

    The service that Uncorrupted provides just does not even compare to other hosting companies. I feel secure in knowing that my site is in excellent hands, and I greatly appreciate the personal attention I receive when I need assistance with the technical aspects of my site.

  • couponing101.com testimonial Stephanie from Couponing 101 says:

    Uncorrupted has far exceeded my hosting expectations! You cannot find a more knowledgeable, helpful, and reliable hosting service anywhere else! The tech support provided is invaluable! You won’t be disappointed with Uncorrupted!

  • FaithfulProvisions.com Testimonial Kelly from Faithful Provisions says:

    I have been with a few other hosting providers and NONE even compared to the service I have received with Michael and Uncorrupted. I promise you, you won’t find service like this anywhere.

More Testimonials
compassion

We're loyal donators to Compassion International, a Christian child advocacy ministry that releases children from spiritual, economic, social and physical poverty and enables them to become responsible, fulfilled Christian adults.





Copyright © 2010 Uncorrupted Hosting. All rights reserved. Follow us on TwitterBe our Facebook Fan
Latest Blog Post:

Playing with snort and pfSense

We've been having a blast with some new intel atom based pfSense firewalls here in the office. The d510 boards perform amazingly well, even with a slew of snort...


Visit our Blog