タグ

mapに関するKumatchのブックマーク (3)

  • nginxでmapモジュールを使って301リダイレクトを行う

    server { listen 80; server_name www.polidog.jp; rewrite ^ $scheme://polidog.jp$request_uri permanent; } リダイレクト先のURLにある程度法則性がある場合は結構サクッとリダイレクトがかけますよね。 世の中めんどくさいリダイレクトを依頼される事がある まあ正規表現でいけるようなリダイレクトの場合はいいんですよ。 ただそうじゃないことってのも夜中ありますよね。 様々な理由でまったく違うページにリダイレクトするとか、、、 そして、ディレクターから大量のリダイレクト表をもらうなんてことがあります。 そんな時に便利なのが ngx_http_map_module です。 HttpMapModuleとはなにか? ngx_http_map_module 標準で入ってるモジュールであるngx_http_ma

    nginxでmapモジュールを使って301リダイレクトを行う
  • [nginx]ホスト名に応じてレスポンスするファイルを振り分ける

    nginx には ngx_http_map_module というハッシュテーブルを操作するモジュールがあり、リクエストヘッダーのホストやユーザーエージェントをキーと見立てて値を振り分けることができる。 このモジュールを使うと、複数のサブドメインをさばいていている時に、robots.txt のような各ドメインに必要なファイルをサブドメインに応じて振り分ける。 ngx_http_map_module の使い方 単純な例 まずは map を使った単純な例から map $http_user_agent $mobile { default 0; "Opera Mini" 1; } これを Python っぽく置き換えると mobile = dict() mobile["Opera Mini"] = 1 というように key-value ペアをまず定義し、リクエスト処理時に mobile.get(ht

  • Blacklist Referer Spam Bots with NGINX

    Some Background Recently, we submitted fadeit.dk to AWWWARDS - the awards for design, creativity and innovation on the Internet. It gave us a nice little boost of website visitors. However, not all of that attention was positive… Referer Spam Bots While the majority of our traffic came from genuine sources, we started noticing a pattern in our referral traffic. What’s up with social-buttons.com? W

    Blacklist Referer Spam Bots with NGINX
  • 1