![]() |
|||||||||
![]() |
![]() |
apache の変更点
#author("2021-02-25T01:36:57+00:00","default:pentacle","pentacle")
* install [#h9aca5a7]
*** open-ssl [#c0ed5ae4]
wget http://www.openssl.org/source/openssl-0.9.8a.tar.gz
tar xvfz ./openssl-0.9.8a.tar.gz
cd openssl-0.9.8a
./config -fPIC shared
make
make install
*** config [#f408508a]
echo '/usr/local/ssl/lib' >> /etc/ld.so.conf
/sbin/ldconfig
*** apache本体 [#o71303e7]
http://www.apache.org/dist/httpd/
wget http://www.apache.org/dist/httpd/httpd-2.0.59.tar.gz
tar xzfp httpd-2.0.5*tar.gz
cd httpd-2.0.5?
./configure --enable-shared=yes --enable-dav=yes \
--enable-so --enable-ssl --enable-modules="so ssl" --with-ssl=/usr/local/ssl
make
make install
*** ssl key 生成 [#ye324e9e]
mkdir /usr/local/apache2/conf/ssl.key
cd /usr/local/apache2/conf/ssl.key
openssl genrsa -des3 -out server.key 1024
mkdir /usr/local/apache2/conf/ssl.crt
cd /usr/local/apache2/conf/ssl.crt
openssl req -new -x509 -days 365 -key ../ssl.key/server.key -out server.crt
cd /usr/local/apache2/conf/ssl.key
openssl rsa -in server.key -out server.key
*** startup [#x0b6598b]
emacs /etc/rc.d/init.d/httpd
[[httpd]]
chmod +x /etc/rc.d/init.d/httpd
chkconfig --add httpd
/etc/rc.d/init.d/httpd start
*** シンボリックリンク [#m72b6a67]
ln -s /usr/local/apache2 /etc/httpd
ln -s /usr/local/apache2/log /var/log/httpd
* httpd.conf [#j00de099]
*** ログ [#w0294195]
CustomLog logs/access_log combined
*** そのディレクトリ以下に cgi と html を共存させる設定 [#h4daa39c]
まず cgi-bin のディレクティブを全削除
<Directory "/var/www/html/">
AllowOverride None
Options +ExecCGI
AddHandler cgi-script .cgi
DirectoryIndex index.cgi index.html
Order allow,deny
Allow from all
</Directory>
*** パスワードをかける設定 [#ra1ae09d]
htpasswd -c /var/www/html/.htpasswd
<Directory "/var/www/html/">
AuthName 【username】
AuthType Basic
AuthUserFile /var/www/html/.htpasswd
Require valid-user
</Directory>
*** バーチャルホスト [#h3acc16c]
NameVirtualHost *
<VirtualHost *>
Servername hogehoge
</VirtualHost>
<VirtualHost *>
</VirtualHost>
バーチャルホストのステータス取得
apache 1.3系 httpd -S
apache 2.0系 httpd- t -D DUMP_VHOSTS
*** ファンシーINDEX [#df803807]
Options Indexes
※ 日本語ファイルが文字化けする場合はそのディレクトリごとに AddDefaultCharset UTF-8 等を加えておく
* プログラム系 [#b79ed9d7]
***きっちり書こうcontent-type [#nd36f922]
METAタグよりhttp-header の content-type が優先される
print 'Content-type: text/html; charset=euc-jp\n\n';
print 'Content-type: text/html; charset=Shift-JIS\n\n';
* IP 制限 [#de0af8f2]
<Location />
Order deny,allow
Deny from all
Allow from 192.168.0.0/24
</Location>
* ius [#m0151038]
yum install https://repo.ius.io/ius-release-el7.rpm
yum remove httpd mod_ssl httpd-tools
yum –disablerepo=base,extras,updates –enablerepo=ius,epel install httpd mod_ssl
ssl.conf を rpmsave から復元して httpd 再起動
* windows 版 [#kff87179]
download してくる
C: 直下に置く Apache24 を置く
cd /cygdrive/c/Apache24/conf
servername の # を消す
cd /cygdrive/c/Apache24/bin
./httpd
常に起動する場合は
./httpd -k install
* セキュリティ設定 [#h4d4ebb7]
''httpd.conf''
Options FollowSymLinks
TraceEnable off
ServerSignature Off
ServerTokens Prod
Header unset X-Powered-By
Options -Indexes
Header always set X-XSS-Protection "1; mode=block"
Header always set X-Content-Type-Options nosniff
Header append X-FRAME-OPTIONS "SAMEORIGIN"
※ ubuntu の場合は下記で header を有効化
sudo a2enmod headers
''ssl.conf''
SSLCompression off
SSLHonorCipherOrder on
# ↓動かなくなるものもあるのでその場合は外す
Header edit Set-Cookie ^(.*)$ $1;secure;HttpOnly
SSLProtocol -ALL +TLSv1.2
SSLCipherSuite !DSS:EDH+AESGCM:ECDSA+AESGCM:EECDH+AESGCM:-AES128
# ちょっと強すぎて動かないものもあるのでその場合は↓
# SSLCipherSuite !3DES:!aNULL:EDH+HIGH:ECDH+HIGH:-AES128:-3DES:-DSS:ECDHE-RSA-AES128-SHA:DHE-RSA-AES128-SHA
''welcome page と icons を削除''
\cp /dev/null /etc/httpd/conf.d/autoindex.conf
\cp /dev/null /etc/httpd/conf.d/welcome.conf
** 診断 [#xfc4196a]
*** SSL [#de4e0bd9]
https://www.ssllabs.com/ssltest/
*** owasp zap [#p496a507]
*** html lint [#k975d4d9]
http://www.htmllint.net/html-lint/htmllint.html
* 特定IPだけ許可その他はパスワ [#jf7c3579]
sudo htdigest -c /etc/httpd/conf/.htdigest "Digest Auth" test
AuthType Digest
AuthName "Digest Auth"
AuthUserFile /etc/httpd/conf/.htdigest
<RequireAny>
Require ip 192.168.0.100/24 10.0.0.1/32
Require valid-user
</RequireAny>
|
|||||||