mod_extract_forwarded

ロードバランサを使うと接続元がロードバランサのIPアドレスになってしまう対策

[code]
# yum –enablerepo=epel install mod_extract_forwarded
[/code]

[code]
# vim /etc/httpd/conf.d/mod_extract_forwarded.conf

LoadModule extract_forwarded_module modules/mod_extract_forwarded.so
MEForder refuse,accept
MEFrefuse all
MEFaccept all
[/code]

mod_deflateで圧縮転送する

コンテンツの転送量を少なくしたいときに

[code]
vim /etc/httpd/conf.d/deflate.conf

DeflateCompressionLevel 5
<Location />
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/rdf+xml

BrowserMatch bMSI[E] !no-gzip !gzip-only-text/html
SetEnvIfNoCase Request_URI.(?:gif|jpe?g|png)$ no-gzip dont-vary
Header append Vary User-Agent env=!dont-vary
FileETag None
</Location>
[/code]

rewriteのアレコレ

強制的にhttpsへ飛ばす
[code]
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^domain.com$
RewriteRule ^/login/?(.*)$ https://domain.com/login/$1 [QSA,R=301]
[/code]

存在しないファイルやディレクトリは全て飛ばす
[code]
DirectoryIndex main.php index.php index.html
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ main.php
[/code]

メンテナンス画面に飛ばす
[code]
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.com$
RewriteRule ^(.*) /maintenance.html [L]
[/code]
[code]
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !maintenance.html$
RewriteRule ^(.*) /maintenance.html [L]
[/code]