Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!

Nginx / Varnish Config

By: pligg on Jun 4th, 2014  |  syntax: None  |  size: 15.41 KB  |  views: 168  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. location /support {
  2.  
  3.         error_page 404 502 = /support/404error.php;
  4.         autoindex off;
  5.        
  6.         if ($uri !~ "(.[a-zA-Z0-9]{1,5}|/)$") {
  7.                 rewrite /(.*)([^/])$ http://$host/support/$1$2/ permanent;
  8.         }
  9.        
  10.         if (!-e $request_filename){
  11.                 ## Re-directing Begin
  12.                 # Story and Category URLs
  13.                 rewrite ^/support/(all)/([^/]+)/?$ /support/story.php?title=$2 last;
  14.                 rewrite ^/support/(all)/?$ /support/index.php last;
  15.  
  16.                 # /recent redirection
  17.                 rewrite ^/support/new/recent/?$ /support/new permanent;
  18.                 rewrite ^/support/new/recent/category/([^/]+)/?$ /support/new/category/$1 permanent;
  19.                 rewrite ^/support/new/recent/page/(\d+)/?$ /support/new/page/$1 permanent;
  20.                 rewrite ^/support/new/recent/category/([^/]+)/page/(\d+)/?$ /support/new/category/$1/page/$2 permanent;
  21.                 rewrite ^/support/recent/?$ /support/./ permanent;
  22.                 rewrite ^/support/recent/category/([^/]+)/?$ /support/category/$1 permanent;
  23.                 rewrite ^/support/recent/page/(\d+)/?$ /support/page/$1 permanent;
  24.                 rewrite ^/support/recent/category/([^/]+)/page/(\d+)/?$ /support/category/$1/page/$2 permanent;
  25.                 rewrite ^/support/new/recent/([^/]+)/?$ /support/new/category/$1 permanent;
  26.                 rewrite ^/support/new/recent/([^/]+)/page/(\d+)/?$ /support/new/category/$1/page/$2 permanent;
  27.                 rewrite ^/support/recent/([^/]+)/?$ /support/category/$1 permanent;
  28.                 rewrite ^/support/recent/([^/]+)/page/(\d+)/?$ /support/category/$1/page/$2 permanent;
  29.                
  30.                 ## RSS
  31.                 rewrite ^/support/new/([^/]+)/rss/?$ /support/rss.php?status=new&category=$1 last;
  32.                 rewrite ^/support/new/rss/?$ /support/rss.php?status=new last;
  33.                 rewrite ^/support/(\d+)/rss/?$ /support/storyrss.php?id=$1 last;
  34.                 rewrite ^/support/([^/]+)/rss/?$ /support/rss.php?category=$1 last;
  35.                 rewrite ^/support/rss/?$ /support/rss.php last;
  36.                 rewrite ^/support/search/([^/]+)/rss/?$ /support/rss.php?search=$1 last;
  37.                 rewrite ^/support/group/([^/]+)/rss/?$ /support/rss.php?status=published&group=$1 last;
  38.                 rewrite ^/support/group/([^/]+)/new/rss/?$ /support/rss.php?status=new&group=$1 last;
  39.                 rewrite ^/support/group/([^/]+)/shared/rss/?$ /support/rss.php?status=shared&group=$1 last;
  40.                 rewrite ^/support/([^/]+)/([^/]+)/rss/?$ /support/storyrss.php?title=$2 last;
  41.                 rewrite ^/support/rss/([a-zA-Z0-9-]+)/?$ /support/rss.php?status=$1 last;
  42.                 rewrite ^/support/rss/category/([^/]+)/?$ /support/rss.php?category=$1 last;
  43.                 rewrite ^/support/rss/category/new/([^/]+)/?$ /support/rss.php?status=new&category=$1 last;
  44.                 rewrite ^/support/rss/category/published/([^/]+)/?$ /support/rss.php?status=published&category=$1 last;
  45.                 rewrite ^/support/rss/category/([^/]+)/new/?$ /support/rss.php?status=new&category=$1 last;
  46.                 rewrite ^/support/rss/category/([^/]+)/published/?$ /support/rss.php?status=published&category=$1 last;
  47.                 rewrite ^/support/rss/category/([^/]+)/group/([^/]+)/?$ /support/rss.php?category=$1&group=$2 last;
  48.                 rewrite ^/support/rss/category/new/([^/]+)/([^/]+)/?$ /support/rss.php?status=new&category=$1&group=$2 last;
  49.                 rewrite ^/support/rss/category/published/([^/]+)/([^/]+)/?$ /support/rss.php?status=published&category=$1&group=$2 last;
  50.                 rewrite ^/support/rss/search/([^/]+)/?$ /support/rss.php?search=$1 last;
  51.                 rewrite ^/support/rssfeeds/?$ /support/rssfeeds.php last;
  52.  
  53.                 ## URL Method 2 Begin ##
  54.  
  55.                 rewrite ^/support/?$ /support/index.php last;
  56.                 rewrite ^/support/advanced-search/?$ /support/advancedsearch.php last;
  57.                 rewrite ^/support/category/([^/]+)/?$ /support/index.php?category=$1 last;
  58.                 rewrite ^/support/category/([^/]+)/([^/]+)/?$ story.php?title=$2 last;
  59.                 rewrite ^/support/login/?$ /support/login.php last;
  60.                 rewrite ^/support/login/([a-zA-Z0-9-]+)/?$ /support/login.php?return=$1 last;
  61.                 rewrite ^/support/login/([a-zA-Z0-9-]+)/([a-zA-Z0-9-]+)/?$ /support/login.php?return=$1/$2 last;
  62.                 rewrite ^/support/logout/?$ /support/login.php?op=logout&return=index.php last;
  63.                 rewrite ^/support/logout/([a-zA-Z0-9-]+)/([a-zA-Z0-9-]+)/?$ /support/login.php?op=logout&return=$1/$2 last;
  64.                 rewrite ^/support/out/([\d]+)/?$ /support/out.php?id=$1 last;
  65.                 rewrite ^/support/out/(https?:.+)$ /support/out.php?url=$1 last;
  66.                 rewrite ^/support/out/([^/]+)/?$ /support/out.php?title=$1 last;
  67.                 rewrite ^/support/register/?$ /support/register.php last;
  68.                 rewrite ^/support/search/([^/]+)/page/(\d+)/?$ /support/search.php?search=$1&page=$2 last;
  69.                 rewrite ^/support/search/(.+)/?$ /support/search.php?search=$1 last;
  70.                 rewrite ^/support/searchurl/(.+)/?$ /support/search.php?url=$1 last;
  71.                 rewrite ^/support/settemplate/?$ /support/settemplate.php last;
  72.                 rewrite ^/support/story/([0-9]+)/?$ /support/story.php?id=$1 last;
  73.                 rewrite ^/support/story/([^/]+)/?$ /support/story.php?title=$1 last;
  74.                 rewrite ^/support/story/([0-9]+)/editcomment/([0-9]+)/?$ /support/edit.php?id=$1&commentid=$2 last;
  75.                 rewrite ^/support/story/([0-9]+)/edit/?$ /support/editlink.php?id=$1 last;
  76.                 rewrite ^/support/submit/?$ /support/submit.php last;
  77.                 rewrite ^/support/tag/([^/]+)/([^/]+)/?$ /support/search.php?search=$1&tag=true&from=$2 last;
  78.                 rewrite ^/support/tag/([^/]+)/?$ /support/search.php?search=$1&tag=true last;
  79.                 rewrite ^/support/tag/([^/]+)/page/(.+)/?$ /support/search.php?search=$1&tag=true&page=$2 last;
  80.                 rewrite ^/support/tagcloud/?$ /support/cloud.php last;
  81.                 rewrite ^/support/tagcloud/range/([0-9]+)/?$ /support/cloud.php?range=$1 last;
  82.                 rewrite ^/support/topusers/?$ /support/topusers.php last;
  83.                 rewrite ^/support/trackback/([0-9]+)/?$ /support/trackback.php?id=$1 last;
  84.                 rewrite ^/support/new/?$ /support/new.php last;
  85.                 rewrite ^/support/new/(year|month|week|today|yesterday|recent|alltime|upvoted|downvoted|commented)/?$ /support/new.php?part=$1 last;
  86.                 rewrite ^/support/new/(year|month|week|today|yesterday|recent|alltime|upvoted|downvoted|commented)/category/([^/]+)/?$ /support/new.php?part=$1&category=$2 last;
  87.                 rewrite ^/support/new/([^/]+)/?$ /support/new.php?category=$1 last;
  88.                 rewrite ^/support/new/page/([0-9]+)/?$ /support/new.php?page=$1 last;
  89.                 rewrite ^/support/new/(year|month|week|today|yesterday|recent|alltime|upvoted|downvoted|commented)/page/(\d+)/?$ /support/new.php?part=$1&page=$2 last;
  90.                 rewrite ^/support/new/(year|month|week|today|yesterday|recent|alltime|upvoted|downvoted|commented)/category/([^/]+)/page/(\d+)/?$ /support/new.php?part=$1&category=$2&page=$3 last;
  91.                 rewrite ^/support/user/search/([^/]+)/?$ /support/user.php?view=search&keyword=$1 last;
  92.                 rewrite ^/support/user/([^/]+)/link/([0-9+]+)/?$ /support/user_add_remove_links.php?action=$1&link=$2 last;
  93.  
  94.                 # Profile
  95.                 rewrite ^/support/user/([^/]+)/profile/?$ /support/user/$1/ permanent;
  96.                 rewrite ^/support/user/([^/]+)/rss/?$ /support/userrss.php?user=$1 last;
  97.                 rewrite ^/support/user/([^/]+)/rss/([a-zA-Z0-9-]+)/?$ /support/userrss.php?user=$1&status=$2 last;
  98.                 rewrite ^/support/user/([^/]+)/edit/?$ /support/profile.php?login=$1 last;
  99.                 rewrite ^/support/user/([^/]+)/([^/]+)/?$ /support/user.php?view=$2&login=$1 last;
  100.                 rewrite ^/support/user/?$ /support/user.php last;
  101.                 rewrite ^/support/user/([^/]+)/?$ /support/user.php?login=$1 last;
  102.                 rewrite ^/support/profile/?$ /support/profile.php last;
  103.        
  104.                 ## Admin
  105.                 rewrite ^/support/admin/?$ /support/admin/admin_index.php last;
  106.                 rewrite ^/support/admin_comments/page/([^/]+)/?$ /support/admin/admin_comments.php?page=$1 last;
  107.                 rewrite ^/support/admin_links/page/([^/]+)/?$ /support/admin/admin_links.php?page=$1 last;
  108.                 rewrite ^/support/admin_users/page/([^/]+)/?$ /support/admin/admin_users.php?page=$1 last;
  109.                 rewrite ^/support/story/([0-9]+)/modify/([a-z]+)/?$ /support/admin/linkadmin.php?id=$1&action=$2 last;
  110.                 rewrite ^/support/view/([^/]+)/?$ /support/admin/admin_users.php?mode=view&user=$1 last;
  111.  
  112.                 ## Groups
  113.                 rewrite ^/support/join_group/action/(published|new|discard)/link/(\d+)/?$ /support/join_group.php?action=$1&link=$2 last;
  114.                 rewrite ^/support/groups/?$ /support/groups.php last;
  115.                 rewrite ^/support/groups/search/([^/]+)/?$ /support/groups.php?view=search&keyword=$1 last;
  116.                 rewrite ^/support/groups/submit/?$ /support/submit_groups.php last;
  117.                 rewrite ^/support/groups/(members|name|oldest|newest)/?$ /support/groups.php?sortby=$1 last;
  118.                 rewrite ^/support/groups/([^/]+)/?$ /support/group_story.php?title=$1 last;
  119.                 rewrite ^/support/groups/([^/]+)/page/([0-9]+)/?$ /support/group_story.php?title=$1&page=$2 last;
  120.                 rewrite ^/support/groups/([^/]+)/?$ /support/group_story.php?title=$1&view=published last;
  121.                 rewrite ^/support/groups/([^/]+)/(published|new|shared|members)/?$ /support/group_story.php?title=$1&view=$2 last;
  122.                 rewrite ^/support/groups/([^/]+)/(published|new|shared|members)/page/([0-9]+)/?$ /support/group_story.php?title=$1&view=$2&page=$3 last;
  123.                 rewrite ^/support/groups/([^/]+)/(published|new|shared|members)/category/([^/]+)/?$ /support/group_story.php?title=$1&view=$2&category=$3 last;
  124.                 rewrite ^/support/groups/([^/]+)/(published|new|shared|members)/category/([^/]+)/page/([0-9]+)?$ /support/group_story.php?title=$1&view=$2&category=$3&page=$4 last;
  125.                 rewrite ^/support/groups/delete/([0-9]+)/?$ /support/deletegroup.php?id=$1 last;
  126.                 rewrite ^/support/groups/edit/([0-9]+)/?$ /support/editgroup.php?id=$1 last;
  127.                 rewrite ^/support/groups/id/([0-9]+)/?$ /support/group_story.php?id=$1 last;
  128.                 rewrite ^/support/groups/join/([0-9]+)/? /support/join_group.php?id=$1&join=true last;
  129.                 rewrite ^/support/groups/member/admin/id/([0-9]+)/role/([a-zA-Z0-9_-]+)/userid/([0-9]+)/?$ /support/groupadmin.php?id=$1&role=admin&userid=$3 last;
  130.                 rewrite ^/support/groups/member/normal/id/([0-9]+)/role/([a-zA-Z0-9_-]+)/userid/([0-9]+)/?$ /support/groupadmin.php?id=$1&role=normal&userid=$3 last;
  131.                 rewrite ^/support/groups/member/moderator/([0-9]+)/role/([a-zA-Z0-9_-]+)/userid/([0-9]+)/?$ /support/groupadmin.php?id=$1&role=$2&userid=$3 last;
  132.                 rewrite ^/support/groups/member/flagged/([0-9]+)/role/([a-zA-Z0-9_-]+)/userid/([0-9]+)/?$ /support/groupadmin.php?id=$1&role=flagged&userid=$3 last;
  133.                 rewrite ^/support/groups/member/banned/id/([0-9]+)/role/([a-zA-Z0-9_-]+)/userid/([0-9]+)/?$ /support/groupadmin.php?id=$1&role=banned&userid=$3 last;
  134.                 rewrite ^/support/groups/page/([0-9]+)/?$ /support/groups.php?page=$1 last;
  135.                 rewrite ^/support/groups/unjoin/([0-9]+)/? /support/join_group.php?id=$1&join=false last;
  136.                 rewrite ^/support/groups/withdraw/([0-9]+)/user_id/([0-9]+)/?$ /support/join_group.php?group_id=$1&user_id=$2&activate=withdraw last;
  137.            
  138.                 ## Live
  139.                 rewrite ^/support/live/?$ /support/live.php last;
  140.                 rewrite ^/support/live/comments/?$ /support/live_comments.php last;
  141.                 rewrite ^/support/live/comments/page/([^/]+)/?$ /support/live_comments.php?page=$1 last;
  142.                 rewrite ^/support/live/published/?$ /support/live_published.php last;
  143.                 rewrite ^/support/live/published/page/([^/]+)/?$ /support/live_published.php?page=$1 last;
  144.                 rewrite ^/support/live/new/?$ /support/live_unpublished.php last;
  145.                 rewrite ^/support/live/new/page/([^/]+)/?$ /support/live_unpublished.php?page=$1 last;
  146.  
  147.                 ## Modules
  148.                 rewrite ^/support/inbox/?$ /support/module.php?module=simple_messaging&view=inbox last;
  149.                 rewrite ^/support/sitemapindex.xml /support/module.php?module=xml_sitemaps_show_sitemap last;
  150.                 rewrite ^/support/sitemap-([a-zA-Z0-9]+).xml /support/module.php?module=xml_sitemaps_show_sitemap&i=$1 last;
  151.                 rewrite ^/support/status/([0-9]+)/?$ /support/modules/status/status.php?id=$1 last;
  152.                 rewrite ^/support/toolbar/(\d+)/?$ /support/modules/pligg_web_toolbar/toolbar.php?id=$1;
  153.                 rewrite ^/support/sitemapindex.xml /support/module.php?module=xml_sitemaps_show_sitemap last;
  154.                 rewrite ^/support/sitemap-([0-9a-z]+).xml /support/module.php?module=xml_sitemaps_show_sitemap&i=$1 last;
  155.  
  156.                 ## Pages
  157.                 rewrite ^/support/about/?$ /support/page.php?page=about last;
  158.                 rewrite ^/support/static/([^/]+)/?$ /support/page.php?page=$1 last;
  159.  
  160.                 ## Pagination
  161.                 rewrite ^/support/category/([^/]+)/page/([^/]+)/?$ /support/index.php?category=$1&page=$2 last;
  162.                 rewrite ^/support/page/([^/]+)/?$ /support/index.php?page=$1 last;
  163.                 rewrite ^/support/page/([^/]+)/([^/]+)category/([^/]+)/?$ /support/index.php?page=$1&part=$2&category=$3 last;
  164.                 rewrite ^/support/new/([^/]+)/page/(\d+)/?$ /support/new.php?category=$1&page=$2 last;
  165.                 rewrite ^/support/published/page/([^/]+)/([^/]+)/?$ /support/index.php?page=$1&category=$2 last;
  166.                 rewrite ^/support/published/page/([^/]+)/([^/]+)/([^/]+)/?$ /support/index.php?page=$1&part=$2&category=$3 last;
  167.                 rewrite ^/support/published/page/([^/]+)/?$ /support/index.php?page=$1 last;
  168.                 rewrite ^/support/published/page/([^/]+)/category/([^/]+)/?$ /support/index.php?page=$1&category=$2 last;
  169.                 rewrite ^/support/published/page/([^/]+)/([^/]+)category/([^/]+)/?$ /support/index.php?page=$1&part=$2&category=$3 last;
  170.                 rewrite ^/support/published/page/([^/]+)/([^/]+)/?$ /support/index.php?page=$1&part=$2 last;
  171.                 rewrite ^/support/published/page/([^/]+)/range/([^/]+)/?$ /support/?page=$1&range=$2 last;
  172.                 rewrite ^/support/search/page/([^/]+)/([^/]+)/?$ /support/search.php?page=$1&search=$2 last;
  173.                 rewrite ^/support/topusers/page/([^/]+)/?$ /support/topusers.php?page=$1 last;
  174.                 rewrite ^/support/topusers/page/([^/]+)/sortby/([^/]+)?$ /support/topusers.php?page=$1&sortby=$2 last;
  175.                 rewrite ^/support/user/page/([^/]+)/([^/]+)/([^/]+)/?$ /support/user.php?page=$1&view=$2&login=$3 last;
  176.                 rewrite ^/support/user/([^/]+)/([^/]+)/page/(\d+)/?$ /support/user.php?page=$3&view=$1&login=$2 last;
  177.            
  178.                 ## Sort
  179.                 rewrite ^/support/(year|month|week|today|yesterday|recent|alltime|upvoted|downvoted|commented)/?$ /support/index.php?part=$1 last;
  180.                 rewrite ^/support/(year|month|week|today|yesterday|recent|alltime|upvoted|downvoted|commented)/category/([^/]+)/?$ /support/index.php?part=$1&category=$2 last;
  181.                 rewrite ^/support/(year|month|week|today|yesterday|recent|alltime|upvoted|downvoted|commented)/page/(\d+)/?$ /support/index.php?part=$1&page=$2 last;
  182.                 rewrite ^/support/(year|month|week|today|yesterday|recent|alltime|upvoted|downvoted|commented)/category/([^/]+)/page/(\d+)/?$ /support/index.php?part=$1&category=$2&page=$3 last;
  183.                 rewrite ^/support/new/(year|month|week|today|yesterday|recent|alltime|upvoted|downvoted|commented)/([^/]+)/?$ /support/new.php?part=$1&category=$2 last;
  184.                 rewrite ^/support/new/(year|month|week|today|yesterday|recent|alltime|upvoted|downvoted|commented)/([^/]+)/page/(\d+)/?$ /support/new.php?part=$1&category=$2&page=$3 last;
  185.                 rewrite ^/support/(year|month|week|today|yesterday|recent|alltime|upvoted|downvoted|commented)/([^/]+)/?$ /support/index.php?part=$1&category=$2 last;
  186.                 rewrite ^/support/(year|month|week|today|yesterday|recent|alltime|upvoted|downvoted|commented)/([^/]+)/page/(\d+)/?$ /support/index.php?part=$1&category=$2&page=$3 last;
  187.  
  188.                 ## URL Method 2 End ##
  189.         }
  190.  
  191.         if (!-e $request_filename){
  192.                 rewrite ^/support/([^/]+)/?$ /support/index.php?category=$1 last;
  193.         }
  194.         if (!-e $request_filename){
  195.                 rewrite ^/support/([^/]+)/page/([^/]+)/?$ /support/index.php?category=$1&page=$2 last;
  196.         }
  197.         if (!-e $request_filename){
  198.                 rewrite ^/support/([^/]+)/([^/]+)/?$ /support/story.php?title=$2&category=$1 last;
  199.                 rewrite ^/support/([^/]+)/([^/]+)/([0-9]+)/?$ /support/story.php?title=$2&category=$1&comment_id=$3 last;
  200.                 rewrite ^/support/([^/]+)/([^/]+)/reply/([0-9]+)/?$ /support/story.php?title=$2&category=$1&comment_id=$3&reply=1 last;
  201.         }
  202.  
  203.         if ($query_string ~* 'mosConfig_[a-zA-Z_]{1,21}(=|\%3D)' ){
  204.                 return 405;
  205.         }
  206.         if ($query_string ~* base64_encode.*\(.*\) ){
  207.                 return 405;
  208.         }
  209.         if ($query_string ~* (\<|%3C).*script.*(\>|%3E) ){
  210.                 return 405;
  211.         }
  212.         if ($query_string ~* 'GLOBALS(=|\[|\%[0-9A-Z]{0,2})' ){
  213.                 return 405;
  214.         }
  215.         if ($query_string ~* '_REQUEST(=|\[|\%[0-9A-Z]{0,2})' ){
  216.                 return 405;
  217.         }
  218.         if ($http_user_agent ~* ^pycurl/){
  219.                 return 405;
  220.         }
  221.  
  222. }