Version 2 (modified by AlexT, 14 years ago) (diff)

--

How to setup Dolphin on Nginx webserver

Nginx is great web-server, many high performance sites are using Nginx. Dolphin can perform better on it too.

First you need to setup Nginx and configure it as usual. This is great documentation resource where you can find all the information about Nginx and how to setup it.

Second step is to turn on serving PHP pages, you can configure it as any other php application using many tutorials here.

The difference in dolphin setup is in rewrite rules, use the following rewrite rules:

        # blogs rewrite
        rewrite "^/path_to_dolphin/blogs[/]{0,1}$"   /path_to_dolphin/modules/boonex/blogs/blogs.php last;        rewrite "^/path_to_dolphin/blogs/all[/]{0,1}$"  /path_to_dolphin/modules/boonex/blogs/blogs.php?action=all last;
        rewrite "^/path_to_dolphin/blogs/all/([0-9]+)/([0-9]+)[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?page=$2&per_page=$1 last;
        rewrite "^/path_to_dolphin/blogs/top[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=top_blogs last;        rewrite "^/path_to_dolphin/blogs/top/([0-9]+)/([0-9]+)[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=top_blogs&page=$2&per_page=$1 last;
        rewrite "^/path_to_dolphin/blogs/top_posts[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=top_posts last;
        rewrite "^/path_to_dolphin/blogs/top_posts/([0-9]+)/([0-9]+)[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=top_posts&page=$2&per_page=$1 last;
        rewrite "^/path_to_dolphin/blogs/tag/([^/.]+)[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=search_by_tag&tagKey=$1 last;
        rewrite "^/path_to_dolphin/blogs/tag[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=search_by_tag&tagKey= last;
        rewrite "^/path_to_dolphin/blogs/posts/([^/.]+)/tag/([^/.]+)[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=search_by_tag&tagKey=$2&ownerName=$1 last;
        rewrite "^/path_to_dolphin/blogs/posts/([^/.]+)/category/([^/.]+)[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=show_member_blog&ownerName=$1&categoryUri=$2 last;
        rewrite "^/path_to_dolphin/blogs/entry/([^/.]+)[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=show_member_post&postUri=$1 last;
        rewrite "^/path_to_dolphin/blogs/entry[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=show_member_post&postUri= last;
        rewrite "^/path_to_dolphin/blogs/posts/([^/.]+)[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=show_member_blog&ownerName=$1 last;
        rewrite "^/path_to_dolphin/blogs/posts[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=show_member_blog&ownerName= last;
        rewrite "^/path_to_dolphin/blogs/posts/([^/.]+)/([0-9]+)/([0-9]+)[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=show_member_blog&ownerName=$1&page=$3&per_page=$2 last;
        rewrite "^/path_to_dolphin/blogs/posts/([^/.]+)/category/([^/.]+)/([0-9]+)/([0-9]+)[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=show_member_blog&ownerName=$1&categoryUri=$2&page=$4&per_page=$3 last;
        rewrite "^/path_to_dolphin/blogs/home[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=home last;
        rewrite "^/path_to_dolphin/blogs/all_posts[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=all_posts last;
        rewrite "^/path_to_dolphin/blogs/popular_posts[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=popular_posts last;
        rewrite "^/path_to_dolphin/blogs/featured_posts[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=featured_posts last;
        rewrite "^/path_to_dolphin/blogs/tags[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=tags last;
        rewrite "^/path_to_dolphin/blogs/show_calendar[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=show_calendar last;
        rewrite "^/path_to_dolphin/blogs/my_page[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=my_page&mode=main last;
        rewrite "^/path_to_dolphin/blogs/my_page/add[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=my_page&mode=add last;
        rewrite "^/path_to_dolphin/blogs/my_page/manage[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=my_page&mode=manage last;
        rewrite "^/path_to_dolphin/blogs/my_page/pending[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=my_page&mode=pending last;
        rewrite "^/path_to_dolphin/blogs/my_page/edit/([0-9]+)[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=edit_post&EditPostID=$1 last;
        rewrite "^/path_to_dolphin/blogs/member_posts/([0-9]+)[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=show_member_blog&ownerID=$1 last;
        rewrite "^/path_to_dolphin/blogs/category/([^/.]+)[/]{0,1}$" /path_to_dolphin/modules/boonex/blogs/blogs.php?action=category&uri=$1 last;

        # ads rewrite
        rewrite "^/path_to_dolphin/ads(/|)$" /path_to_dolphin/modules/boonex/ads/classifieds.php?Browse=1 last;
        rewrite "^/path_to_dolphin/ads/my_page[/]*$" /path_to_dolphin/modules/boonex/ads/classifieds.php?action=my_page last;
        rewrite "^/path_to_dolphin/ads/my_page/add[/]*$" /path_to_dolphin/modules/boonex/ads/classifieds.php?action=my_page&mode=add last;
        rewrite "^/path_to_dolphin/ads/my_page/edit/([0-9]+)[/]*$" /path_to_dolphin/modules/boonex/ads/classifieds.php?action=my_page&mode=add&EditPostID=$1 last;
        rewrite "^/path_to_dolphin/ads/my_page/edit/([0-9]+)/dimg/([0-9]+)[/]*$" /path_to_dolphin/modules/boonex/ads/classifieds.php?action=my_page&mode=add&EditPostID=$1&dimg=$2 last;
        rewrite "^/path_to_dolphin/ads/my_page/manage[/]*$" /path_to_dolphin/modules/boonex/ads/classifieds.php?action=my_page&mode=manage last;
        rewrite "^/path_to_dolphin/ads/my_page/pending[/]*$" /path_to_dolphin/modules/boonex/ads/classifieds.php?action=my_page&mode=pending last;
        rewrite "^/path_to_dolphin/ads/my_page/disapproved[/]*$" /path_to_dolphin/modules/boonex/ads/classifieds.php?action=my_page&mode=disapproved last;
        rewrite "^/path_to_dolphin/ads/cat/([^/.]+)[/]*$" /path_to_dolphin/modules/boonex/ads/classifieds.php?catUri=$1 last;
        rewrite "^/path_to_dolphin/ads/all/cat/([0-9]+)/([0-9]+)/([^/.]+)[/]*$" /path_to_dolphin/modules/boonex/ads/classifieds.php?catUri=$3&page=$2&per_page=$1 last;
        rewrite "^/path_to_dolphin/ads/subcat/([^/.]+)[/]*$" /path_to_dolphin/modules/boonex/ads/classifieds.php?scatUri=$1 last;
        rewrite "^/path_to_dolphin/ads/all/subcat/([0-9]+)/([0-9]+)/([^/.]+)[/]*$" /path_to_dolphin/modules/boonex/ads/classifieds.php?scatUri=$3&page=$2&per_page=$1 last;
        rewrite "^/path_to_dolphin/ads/entry/([^/.]+)[/]*$" /path_to_dolphin/modules/boonex/ads/classifieds.php?entryUri=$1 last;
        rewrite "^/path_to_dolphin/ads/tag/([^/.]+)[/]*$" /path_to_dolphin/modules/boonex/ads/classifieds_tags.php?tag=$1 last;
        rewrite "^/path_to_dolphin/ads/calendar[/]*$" /path_to_dolphin/modules/boonex/ads/classifieds.php?action=show_calendar last;
        rewrite "^/path_to_dolphin/ads/categories[/]*$" /path_to_dolphin/modules/boonex/ads/classifieds.php?action=show_categories last;
        rewrite "^/path_to_dolphin/ads/tags[/]*$" /path_to_dolphin/modules/boonex/ads/classifieds.php?action=tags last;
        rewrite "^/path_to_dolphin/ads/all_ads[/]*$" /path_to_dolphin/modules/boonex/ads/classifieds.php?action=show_all_ads last;
        rewrite "^/path_to_dolphin/ads/top_ads[/]*$" /path_to_dolphin/modules/boonex/ads/classifieds.php?action=show_top_rated last;
        rewrite "^/path_to_dolphin/ads/popular_ads[/]*$" /path_to_dolphin/modules/boonex/ads/classifieds.php?action=show_popular last;
        rewrite "^/path_to_dolphin/ads/featured_ads[/]*$" /path_to_dolphin/modules/boonex/ads/classifieds.php?action=show_featured last;

        # search by tag rewrite
        rewrite "^/path_to_dolphin/search/tag/([^/.]+)[/]*$" /path_to_dolphin/search.php?Tags=$1 last;

        # browse members rewrite
        rewrite "^/path_to_dolphin/browse/([^/.]+)/([^/.]+)/([^/.]+)$" /path_to_dolphin/browse.php?sex=$1&age=$2&country=$3 last;

        # forum rewrite
        rewrite "^/path_to_dolphin/forum/groups/(.*)$" /path_to_dolphin/forum/$1?orca_integration=groups;
        rewrite "^/path_to_dolphin/forum/events/(.*)$" /path_to_dolphin/forum/$1?orca_integration=events;
        rewrite "^/path_to_dolphin/forum/store/(.*)$" /path_to_dolphin/forum/$1?orca_integration=store;
        rewrite "^/path_to_dolphin/forum/$" /path_to_dolphin/modules/boonex/forum/index.php last;
        rewrite "^/path_to_dolphin/forum/(.*)$" /path_to_dolphin/forum/$1;

        rewrite "^/path_to_dolphin/forum/group/(.+)\.htm$" /path_to_dolphin/modules/boonex/forum/index.php?action=goto&cat_id=$1 last;
        rewrite "^/path_to_dolphin/forum/forum/(.+)-([0-9]+)\.htm$" /path_to_dolphin/modules/boonex/forum/index.php?action=goto&forum_id=$1&start=$2 last;
        rewrite "^/path_to_dolphin/forum/forum/(.+)\.htm$" /path_to_dolphin/modules/boonex/forum/index.php?action=goto&forum_id=$1&start=0 last;
        rewrite "^/path_to_dolphin/forum/topic/(.+)\.htm$" /path_to_dolphin/modules/boonex/forum/index.php?action=goto&topic_id=$1 last;
        rewrite "^/path_to_dolphin/forum/user/(.+)\.htm$" /path_to_dolphin/modules/boonex/forum/index.php?action=goto&user=$1 last;

        rewrite "^/path_to_dolphin/forum/rss/forum/(.+)\.htm$" /path_to_dolphin/modules/boonex/forum/index.php?action=rss_forum&forum=$1 last;
        rewrite "^/path_to_dolphin/forum/rss/topic/(.+)\.htm$" /path_to_dolphin/modules/boonex/forum/index.php?action=rss_topic&topic=$1 last;
        rewrite "^/path_to_dolphin/forum/rss/user/(.+)\.htm$" /path_to_dolphin/modules/boonex/forum/index.php?action=rss_user&user=$1 last;
        rewrite "^/path_to_dolphin/forum/rss/all\.htm$" /path_to_dolphin/modules/boonex/forum/index.php?action=rss_all&sort= last;

        rewrite "^/path_to_dolphin/forum/(.*)$" /path_to_dolphin/modules/boonex/forum/$1 last;

        # pages rewrite
        rewrite "^/path_to_dolphin/page/(.*)$" /path_to_dolphin/viewPage.php?ID=$1 last;

        # modules rewrite 
        rewrite ^/path_to_dolphin/m/(.*)$ /path_to_dolphin/modules/index.php?r=$1 last;

        # profile rewrite
        if (!-e $request_filename ) {
            rewrite  ^/path_to_dolphin/([^/]+)$  /path_to_dolphin/profile.php?ID=$1  last;
            break;
        }

Now everything should work, but some optimisation is needed. Add the following rules to tell Nginx to server static files directly, it will also tell user's browser to cache them for 1 month:

    # serve static files directly
    location ~* ^\/path_to_dolphin.+(templates|flash|media|plugins)\/.+\.(jpg|jpeg|gif|css|png|js|ico)$ {
        access_log        off;
        expires           30d;
    }

If you don't have below lines in your Nginx configuration it is better to add it too:

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    location ~ /\.ht {
        deny  all;
    }

Replace path_to_dolphin to your real path in all above configurations, or if Dolphin is installed in root folder of your domain then just remove /path_to_dolphin part from every rule. Place above rules to location { clause for your particular Dolphin folder.

Some more optimisation is possible, add these lines to http { clause of Nginx configuration file to enable on the fly compression:

    gzip_http_version 1.1;
    gzip_min_length 200;
    gzip_vary on;
    gzip_comp_level 6;
    gzip_proxied any;
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
    gzip_buffers 16 8k;

All the optimisation steps described here are already applied in above configurations.

 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.
Fork me on GitHub