Apache

mod_rewrite まとめ

準備 SSLProxyEngine On #httpsのURLに転送ではなくてリバースプロキシーする場合には、Onにしておく RewriteEngine On #必ずOnにしておく RewriteLog "logs/rewrite_log" #デバッグに非常に便利 (/var/log/httpd/rewrite_log) RewriteLogLevel 9 #9が最高。…

何もしないOutputfilterのサンプル

http://asp.mi.hama-med.ac.jp/web/ のソースをほとんどそのままコピー。これを元に改造していく。いつものように、 # apxs -g -n myoutputfilter mod_myoutputfilter.conf LoadModule myoutputfilter_module modules/mod_myoutputfilter.so SetOutputFilter…

POSTされたデータをパースするApacheモジュール

CentOS5.1 上の Apache2.2のサンプル。libapreq2 を使用。 libapreq2 のインストールには、あらかじめEPELレポジトリの追加が必要。 # rpm -ivh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-1.noarch.rpm # yum install libapreq2-de…

内部リダイレクトするApacheモジュール

CentOS5.1 上の Apache2.2のサンプル。 #include "httpd.h" #include "http_config.h" #include "http_protocol.h" #include "ap_config.h" static int myinternalredirect_handler(request_rec *r) { ap_internal_redirect("/hello", r); return OK; } stat…

外部リダイレクトするApacheモジュール

CentOS5.1 上の Apache2.2のサンプル。 #include "httpd.h" #include "http_config.h" #include "http_protocol.h" #include "apr_tables.h" #include "ap_config.h" /* The sample content handler */ static int myredirect_handler(request_rec *r) { apr…

QUERY_STRING をパースするApacheモジュール

CentOS5.1 上の Apache2.2のサンプル。 mod_mygetparse の作成 # apxs -g -n mygetparse # cd mygetparse # make # make install/etc/httpd/conf.d/mod_mygetparse.conf を以下のように作成 LoadModule mygetparse_module modules/mod_mygetparse.so <Location /mygetparse> SetHan</location>…

Apacheモジュール 1.3から2.2への移植: mod_reqinfo

Apacheモジュール プログラミングガイド の中のサンプルプログラムをApache1.3からApache2.2に書き換えたのでそのときのメモ。 #include "httpd.h" #include "http_config.h" #include "http_protocol.h" #include "http_core.h" #include "ap_config.h" /* …

Apache 本体の関数プロトタイプ一覧

# grep AP_DECLARE *.h ap_config.h: * AP_DECLARE_STATIC is defined when including Apache's Core headers, ap_config.h: * @see AP_DECLARE_EXPORT ap_config.h: * AP_DECLARE_STATIC and AP_DECLARE_EXPORT are left undefined when ap_config.h:# defi…

apacheモジュール作成のまとめ

かなり自分用。 hello world の作成 # apxs -g -n hello <- これで雛形ができる。 # cd hello # make # make install/etc/httpd/conf.d/mod_hello.conf を以下のように作成 LoadModule hello_module modules/mod_hello.so <Location /hello> SetHandler hello </Location>apache 再起動&…

APR 関数プロトタイプ一覧

# grep APR_DECLARE *.h apr_allocator.h:APR_DECLARE(apr_status_t) apr_allocator_create(apr_allocator_t **allocator); apr_allocator.h:APR_DECLARE(void) apr_allocator_destroy(apr_allocator_t *allocator); apr_allocator.h:APR_DECLARE(apr_memnod…

apache2.2のソースに付属されてくるmod_example.c

自分用に転載 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licen…

CentOS5.1 用のApache1.3のRPM作成

checkinstall というプログラムを使えば、ソースファイルから任意のプラットフォーム向けのRPMやdebファイルを作成するできるらしい。実に胡散臭い。でも試してみたのでそのときのメモ。 準備 checkinstall のRPMを rpmfind.net などから探してインストール…

apache1.3.37 で、FD_SETSIZE 関連のエラー

CentOS 4で、非常に多数の virtual_host を設定している場合、 [Sat Aug 11 08:26:17 2007] [warn] make_sock: problem listening on port 443, filedescriptor (1217) larger than FD_SETSIZE (1024) found, you probably need to rebuild Apache with a la…

Apache1.3でSSLの設定メモ

# cd /etc/httpd/conf # openssl genrsa -out server.key 1024 ssl.key/server.key # openssl req -new -x509 -days 365 -key ssl.key/server.key -out ssl.crt/server.crt /etc/httpd/conf/httpd.conf の中を以下のように編集 SSLCertificateFile /etc/http…

アパッチモジュールのデバッグのメモ

Apache1.3のモジュールで、どうやらバグが出ている。再現する環境と再現しない環境がある。大き目のデータをuploadした際に発生している。メモリ関連か? apacheのコンパイル # export CFLAGS=-g # ./configure # make # make install デバッグ # gdb /usr/s…

Apacheモジュールメモ

モジュール作成 apxs -g -n helloworld cd helloworld make make install/etc/httpd/conf.d/helloworld.conf を以下のように作成 LoadModule helloworld_module modules/mod_helloworld.so <Location /helloworld> SetHandler helloworld </Location>以下のようにした場合は、.hw で終わるファ…

WEBアプリケーション速さ比較

C言語にはClearSilverというテンプレートエンジンがあるらしい。 WEBアプリはApacheモジュールで作れば一番速そうだけど、テンプレートエンジン使うとどうなのかなと思いテストしてみた。 結論 Resinが断トツで速かった。Apacheモジュール+ClearSilverより…

How to make a self-signed certificate 自己署名の作成方法

http://www.kozupon.com/security/ssl_source.html

refererによるアクセス制限

httpd.conf を以下のように編集する <Directory /> Options FollowSymLinks # AllowOverride None AllowOverride All <- これ </Directory> 例 http://www.hatena.ne.jp/以下のページからのリンクのみ許可 SetEnvIf Referer "^http://www\.hatena\.ne\.jp" ref_ok order deny,allow de…

Fedora Core 5 上でのmod_perlのセットアップ

オリジナルは、naoyaの「10分で完了、mod_perl 2.0 で Hello, World!」d:id:naoya:20060108:1136692447/etc/httpd/conf.d/naoya.conf という名前で以下を作成 NameVirtualHost *:80 <VirtualHost *:80> ServerName fc5:80 PerlModule mod_perl PerlRequire /var/www/mod_perl/s</virtualhost>…

アクセスログのフィルタ方法

/etc/httpd/conf/httpd.conf の中を以下のように修正。例:CSSファイル、画像ファイル、JavaScriptなどをフィルタする場合。 SetEnvIf Request_URI "^/wm/css/" dontlog SetEnvIf Request_URI "^/wm/img/" dontlog SetEnvIf Request_URI "^/wm/js/" dontlog …