apache 2.2系に openssl 1.0系は使えません。 0.9.8を使いましょう - end0tknrのkipple - web写経開発
先日の↑こちらのエントリに関連するかもしれません。
概要
https
httpでアクセスしても、mod_rewriteでhttpsへredirect?します
RewriteCond , RewriteRuleによるURL毎のreverse proxy
host名以下のpath(url)により、サービス本体を提供するhostが異なる為、RewriteCond , RewriteRuleによる振分けを行っています。
SetEnvIf Request_URIによるURL毎にアクセスログ分割
host名以下のpath(url)により、アクセスログを分ける為、httpd.conf で、「SetEnvIf Request_URI 〜」を使っています。
のようなことを実現したいなら、httpd.conf , httpd-ssl.confは以下のようになります。
confファイルの必要な部分にコメントを入れています
httpd.conf
ServerRoot "/usr/local/apache22" Listen 80 LoadModule rewrite_module modules/mod_rewrite.so <IfModule !mpm_netware_module> <IfModule !mpm_winnt_module> User daemon Group daemon </IfModule> </IfModule> ServerAdmin you@example.com DocumentRoot "/home/endo/local/apache22_80/htdocs" <Directory /> Options FollowSymLinks AllowOverride None Order deny,allow Deny from all </Directory> <Directory "/usr/local/apache22/htdocs"> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory> <IfModule dir_module> DirectoryIndex index.html </IfModule> <FilesMatch "^\.ht"> Order allow,deny Deny from all Satisfy All </FilesMatch> ErrorLog "/home/endo/local/apache22_80/logs/error_log" LogLevel warn <IfModule log_config_module> LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined LogFormat "%h %l %u %t \"%r\" %>s %b" common <IfModule logio_module> LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio </IfModule> CustomLog "/home/endo/local/apache22_80/logs/access_log" common #CustomLog "logs/access_log" combined </IfModule> <IfModule alias_module> </IfModule> <IfModule cgid_module> </IfModule> <Directory "/usr/local/apache22/cgi-bin"> AllowOverride None Options None Order allow,deny Allow from all </Directory> DefaultType text/plain <IfModule mime_module> TypesConfig conf/mime.types AddType application/x-compress .Z AddType application/x-gzip .gz .tgz </IfModule> <IfModule ssl_module> SSLRandomSeed startup builtin SSLRandomSeed connect builtin </IfModule> #mod_rewriteは設定が難しいので、debug用のlogを出力 RewriteEngine on RewriteLog "/home/endo/local/apache22_80/logs/rewrite.log" RewriteLogLevel 1 #httpによるroot直下へのアクセスは、httpsへredirect RewriteRule ^/$ https://colinux.a4.jp/ [R=301,L] ProxyRequests Off
httpd-ssl.conf
Listen 443 AddType application/x-x509-ca-cert .crt AddType application/x-pkcs7-crl .crl SSLPassPhraseDialog builtin SSLSessionCache "shmcb:/usr/local/apache22/logs/ssl_scache(512000)" SSLSessionCacheTimeout 300 SSLMutex "file:/usr/local/apache22/logs/ssl_mutex" <VirtualHost _default_:443> DocumentRoot "/home/endo/local/apache22_80/htdocs" ServerName colinux.a4.jp:443 ServerAdmin you@example.com ErrorLog "/usr/local/apache22/logs/error_log" TransferLog "/usr/local/apache22/logs/access_log" SSLEngine on SSLProtocol all -SSLv2 SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5 SSLCertificateFile "/usr/local/apache22/conf/sslkeys/newcert.pem" SSLCertificateKeyFile "/usr/local/apache22/conf/sslkeys/newkey.pem" <FilesMatch "\.(cgi|shtml|phtml|php)$"> SSLOptions +StdEnvVars </FilesMatch> <Directory "/usr/local/apache22/cgi-bin"> SSLOptions +StdEnvVars </Directory> BrowserMatch "MSIE [2-5]" \ nokeepalive ssl-unclean-shutdown \ downgrade-1.0 force-response-1.0 CustomLog "/usr/local/apache22/logs/ssl_request_log" \ "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b" #mod_rewriteは設定が難しいので、debug用のlogを出力 RewriteEngine on RewriteLog "/home/endo/local/apache22_80/logs/rewrite.log" RewriteLogLevel 1 #https内であっても必要な場合、redirect RewriteCond %{REQUEST_URI} !^(/XingG/.*)$ [NC] RewriteRuleo ^/$ https://colinux.a4.jp/xxack [R=301,L] #basic認証に失敗した場合、用意した権限エラーページを表示 ErrorDocument 401 /error/authen-error.html ProxyRequests Off <LocationMatch "/"> Order allow,deny Allow from all </LocationMatch> #path(url)により、アクセスログを分ける CustomLog "/home/endo/local/apache22_80/logs/xxack-access_log" common env=xxack_log CustomLog "/home/endo/local/apache22_80/logs/xingg-access_log" common env=xingg_log SetEnvIf Request_URI "^/xxack" xxack_log SetEnvIf Request_URI "^/XingG" xingg_log #サービス本体へreverse proxy <Location "/xxack"> AuthType Basic AuthName XXACK_MEMBER AuthUserFile /home/endo/dev/htpasswd2 Require valid-user ProxyPass http://colinux.a4.jp:8081/xxack ProxyPassReverse http://colinux.a4.jp:8081/xxack </Location> #サービス本体へreverse proxy <LocationMatch "/XingG"> AuthType Basic AuthName SING_MEMBER AuthUserFile /home/endo/dev/htpasswd Require valid-user ProxyPass http://colinux.a4.jp:8081/XingG ProxyPassReverse http://colinux.a4.jp:8081/XingG </LocationMatch> </VirtualHost>
その他 - mod_rewriteのデバッグには、RewriteLog を使いましょう
httpd.conf , httpd-ssl.conf に次のように書きます
RewriteEngine on RewriteLog "/home/endo/local/apache22_80/logs/rewrite.log" RewriteLogLevel 1
mod_rewriteの設定方法は、例えば、次のurlに分かりやすく記載されています。
http://blog.dawgsdk.org/weblog/archives/411011