スキップしてメイン コンテンツに移動

投稿

2017の投稿を表示しています

VirtualHost とデフォルトサイト

これは常識なのかもしれないけど、 ・サイトは、すべて VirtualHost で定義する。 ・VirtualHost 定義の一番先頭に、 <VirtualHost *:80> </VirtualHost> ってだけ書いておく。 ・IP直打ちでアクセスされたときのために、デフォルトのドキュメントルート(/var/www/html)は空にしておく。 ・VirtualHostの定義は、httpd.conf の一番最後で行う。サイトごとに別ファイルで定義するときは、httpd.conf の一番最後で Include する。 ・名前ベースのバーチャルホストでSSLする。 ってことをするようにした。 こうすることで、 ・IP直打ちアクセスや意図しないHOST_NAMEでのアクセスは、全部、デフォルトのドキュメントルートへ流す。 ことができて、これらの意図しないアクセスはすべて 403 で捌けるなと。 でも、その前の前提として、httpd.conf で <Directory "/var/www/html">  Options -Indexes +FollowSymLinks ・・・ </Directory> ってしておくことと、 # rm /etc/httpd/conf.d/welcome.conf  って消しておいてね

http/https のセッション数 を netstat の state ごとに表示する

watch使う場合、sed -e 's/[^A-Z]*//' がみそ。 もし sed -e 's/[^A-Z]*//' がなかった場合どうなるかは、試してみて。 watch -n 1 "netstat -ant | egrep ':(80|443) '| egrep 'EST|SYN|FIN|CLOSE'| awk {'print $6'} | sed -e 's/[^A-Z]*//' | sort | uniq -c" こんなのも watch -n 2 "netstat -etpon | egrep ':(80|443) ' | egrep 'EST|SYN|FIN|CLOSE'"

Aレコードさえあればメールは届く

俺:80%?冗談じゃない、この設定で100%メールは届きます。 無能:MXレコードは定義されていない? 俺:あんなの飾りです。MXレコードなんてなくても、www.example.comでAレコードさえ定義してあれば、 apache@www.example.com っていう Return-Path にも、メールは返ってくるんです。

smtpd_xxxxx_restrictions

HELOコマンドの際に適用される制限リスト smtpd_helo_restrictions RCPTコマンドで宛先指定時に適用される制限リスト smtpd_recipient_restrictions DATAコマンドの受信段階に適用される制限リスト smtpd_data_restrictions DATAコマンドの終了段階に適用される制限リスト smtpd_end_of_data_restrictions ETRNコマンドの受信段階に適用される制限リスト smtpd_etrn_restrictions リレー時に適用される制御リスト smtpd_relay_restrictions ( >= 2.10 ) CentOS 6.7 postfix 2.6 のデフォルト smtpd_client_restrictions = smtpd_data_restrictions = smtpd_end_of_data_restrictions = smtpd_etrn_restrictions = smtpd_helo_restrictions = smtpd_recipient_restrictions = permit_mynetworks, reject_unauth_destination smtpd_restriction_classes = smtpd_sender_restrictions = CentOS 7 postfix 2.10 のデフォルト smtpd_client_restrictions = smtpd_data_restrictions = smtpd_end_of_data_restrictions = smtpd_etrn_restrictions = smtpd_helo_restrictions = smtpd_recipient_restrictions = smtpd_relay_restrictions = permit_mynetworks, permit_sasl_authenticated, defer_unauth_destination smtpd_restriction_classes = smtpd_sender_rest...

postfix の再送間隔

postfix 2.10.1 のデフォルト設定は以下。 送信失敗 -> deferredに入れる queue_run_delay(300秒)毎にdeferredをチェック minimal_backoff_time(300秒)を超えるメールがあれば送信 また失敗したらminimal_backoff_timeの倍(600秒)の時間後に再送 またまた失敗したらminimal_backoff_timeの倍の倍(1200秒)の時間後に再送 その後も失敗したら倍々しながら再送 maximal_backoff_time(4000秒)を超えるまでこれを繰り返し maximal_backoff_timeを超えてしまったら、maximal_backoff_time間隔で再送 maximal_queue_lifetime(5日)を超えてしまったら再送をあきらめる bounce_queue_lifetime(5日)を超えたら送信もとにエラーメール送信

なんだろ?うちの社長

うちの社長が仲のいい社長連中と、お互い奥さん同伴で3年に1回の旅行していた。 自分とこの一番大事なお客さんへの納品日に。 しかも、社員は連休つぶしてるっていうのに、 一番大事なお客さんの納品日だぞ? しかも、今期も一番の取引額のお客さんだぞ? そんなにその3年に1回の旅行は大事か? 俺は仕事忙しくて、新婚旅行も行けなかったっていうのに・・・ 2か月に1回の飲み会だった。 社長も一緒。 何の話の延長だったか、子供の話になって。 「俺、息子に言われて忘れられない言葉がある」 って俺が切り出して、一緒に飲んでいた女性が「何?」って感じで聞いてくれたので 「あ、お父さん久しぶり」 って。 そしたら、社長 「そんなになるまで会社にいるのもどうかしてるけど」 って半分呆れた感じ言いやがったから、ぶっちーんってキレた。 「某マスコミのあの仕事してたときなんですけど」 って言ってやったら、オレを無視して、ほかの社員と違う話し始めやがった。 悪かったの一言もなしかよ。 だよね、あんたには、全部他人事だよね。

apache 2.4 の ServerName

[root@sv00 ~]# cat /etc/httpd/conf/httpd.conf ~ #ServerName www.example.com:80 ~ <VirtualHost *:80> # Default VirtualHost # Use Main Setting </VirtualHost> <VirtualHost *:80> ServerName sv01.example.dom DocumentRoot /var/www/html/sv01 </VirtualHost> [root@sv00 ~]# hostname sv00.example.com [root@sv00 ~]# httpd -S VirtualHost configuration: *:80 is a NameVirtualHost default server sv00.example.com (/etc/httpd/conf/httpd.conf:357) port 80 namevhost sv00.example.com (/etc/httpd/conf/httpd.conf:357) port 80 namevhost sv01.example.dom (/etc/httpd/conf/httpd.conf:361) ServerRoot: "/etc/httpd" Main DocumentRoot: "/var/www/html" ~ こんな感じで、hostname が FQDN で設定されていると、default の ServerName は hostname が使用される。 hostname が 「sv00」だけだと [root@sv00 ~]# apachectl configtest AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 192:168:0:1. Set the 'ServerName' directive globally to s...

find でパーミッションとオーナー・グループを条件に検索して パーミッションを変更する

オーナー hoge に 644 与えてある /var/www/html 配下のファイルのパーミッションを 664 に変更する。 # find /var/www/html -perm 644 -type f -user hoge -print0 | xargs -0 chmod 664 グループ hoge に 644 与えてある /var/www/html 配下のファイルのパーミッションを 664 に変更する。 # find /var/www/html -perm 644 -type f -group hoge -print0 | xargs -0 chmod 664 オーナー hoge に 755 与えてある /var/www/html 配下のディレクトリのパーミッションを 775 に変更する。 # find /var/www/html -perm 755 -type f -user hoge -print0 | xargs -0 chmod 775 グループ hoge に 755 与えてある /var/www/html 配下のディレクトリのパーミッションを 775 に変更する。 # find /var/www/html -perm 755 -type f -group hoge -print0 | xargs -0 chmod 775

DNS の TTL と minimum値

TTL:存在することをキャッシュしておく時間。 minimum:存在しないことをキャッシュしておく時間。 なので、example.com ドメインに新しく hoge.example.com というホストを追加する場合、事前に TTLを短くしておいても minimum値が長かったら、minimum値の間は名前解決できない。