apache

外部機関の脆弱性診断を受けて対応した

ssh hoge ディレクトリリスティング無効化 cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.orig vim /etc/httpd/conf/httpd.conf # Directory Listing Denied Alias /icons/ "/var/www/icons/" <Directory "/var/www/icons"> # Options MultiViews Indexes FollowSymLinks Op</directory>…

MAMPのApacheが起動しない

MAMPで Apache couldn't be started. Please check your MAMP installation and configuration. となる場合、Mac標準のapacheと干渉している場合がある。 apachectl status apachectl stop

.htaccessでのIP制限

hogehoge/foo以下を123.456.789.0以外からアクセスできないようにする。 # restrict uri <IfModule mod_rewrite.c> RewriteEngine On #RewriteBase / RewriteCond %{REQUEST_URI} ^.*/foo.*$ RewriteCond %{REMOTE_ADDR} !123.456.789.0 RewriteRule ^(.*)$ / [R=301,L] </IfModule>

301リダイレクトの書き方

ssl設定したあとは.htaccessをこんな感じで編集する。 RewriteEngine On RewriteCond %{HTTP_HOST} ^www\.foo\.jp$ RewriteRule (.*) https://foo.jp/$1 [R=301,L] RewriteEngine On RewriteCond %{HTTP_HOST} ^bar\.jp$ RewriteRule (.*) https://foo.jp/$1…

sslをlet's encryptから、買ってきたのものに変更

SSL切り替え Let's Encryptの要領でやった。 Apache + OpenSSL 中間CA証明書のインストール手順 SSL証明書切り替え プライベートキー:foo_key.pem SSL証明書:fullchain.crt SSLサーバ証明書:cert.crt(SSL証明書の上半分コピペ) 中間証明書:chain.crt(SSL…