Blog

  • AWSにリバースプロキシーを構築

    「AWSにプロキシを構築」の続き

    ・セキュリティの設定
     AWSのセキュリティグループ
      インバウンドにルールを追加する
       TCP、80、0.0.0.0/0
     Windowsファイアウォールにてsquis.exeの入力規則にTCPプロトコルの80ポートを追加する

    ・squidの設定
     squid_reverse.confの作成(抜粋)

    #Privarte IPの80番ポートで待ち受ける
    #accelモード(リバプロ)で稼働するaccelモード(リバプロ)で稼働する
    #ブラウザのキャッシュコントロールを無効にする
    http_port 80 accel defaultsite=xxx.xxx.xxx.xxx ignore-cc
    
    visible_hostname www.chombo.work
    
    pid_filename /var/run/${service_name}.pid
    
    cache_peer domain.org parent 80 0 no-query originserver
    
    max_filedescriptors 3200
    
    #エラー画面の設定
    #/usr/share/squid/createdErrPage内に独自のエラーページ作成
    #Squidを隠蔽するため、全エラーを404で返す
    #デフォルトだとアクセス制御で拒否されたらSquidは403を返す
    #404.htmlは適当に作成し、error_directory内に格納する
    error_directory /usr/share/squid/createdErrPage
    deny_info 404:404.html dmz
    deny_info 404:404.html all
    #クライアントのIPアドレスをそのままWebサーバへ渡す
    forwarded_for on
    
    #Squidを使用していることを隠蔽するため各種htmlヘッダを削除
    #Webサーバが返すServerヘッダも削除される
    reply_header_access X-Squid-Error deny all
    reply_header_access X-Cache deny all
    reply_header_access Via deny all
    reply_header_access Server deny all
    
    #コンテンツキャッシュを行わない設定
    acl nocache src all
    cache deny nocache
    cache_store_log none
    
    #エラーページをキャッシュしない(保有時間を0秒に)
    negative_ttl 0 seconds
    
    #Only allow cachemgr access from localhost
    http_access allow all
    
    #Deny requests to certain unsafe ports
    http_access deny !Safe_ports
    
    #Deny CONNECT to other than secure SSL ports
    http_access deny CONNECT !SSL_ports
    
    #And finally deny all other access to this proxy
    http_access deny all
    
    logformat squidReverse %tl %6tr %>a %Ss/%03>Hs %
    
    #ログファイル名を指定
    access_log stdio:/var/log/squid/accessReverse.log squidReverse
    
    #Squidに関するエラー・デバックログを記録するファイル名を指定
    cache_log /var/log/squid/cacheReverse.log
    
    #ログを13世代保有する
    logfile_rotate 13

    ・squidの起動

    squid -f /etc/squid/squid_reverse.conf -n squidReverse -N

    をタスクマネージャに登録
     Diladele.Squid.Tray.exeのStop Squid Serviceでプロキシーを止めた場合、同時にリバースプロキシ―も止まるので注意

    ・DMSの登録
     Elastic IPをMyDNSに固定アドレスとして登録
      IPアドレスの通知は定期的に行う必要がある。通知するIPアドレスは無視される模様

    ・クライアントのIPアドレスが変わった場合
     セキュリティグループのインバウンドを変更(8080,3389)
     squid.conf,squid_reverse.confを変更
     MyDNS.comにAWSからログイン

    ・EC2のPrivate IPが変わった場合
     セキュリティグループのインバウンドを変更
     squid.conf,squid_reverse.confを変更

    ・ディスククリーンアップを追加
     PowerShellでAdd-WindowsFeature Desktop-Experience

  • AWSにプロキシーを構築

    ・AWSアカウントの作成
     電話の非通知着信拒否を一時解除

    ・リージョンの変更
     AWSコンソールにログインして右上のリージョンを東京に変更

    ・インスタンスの作成
     AMIからWordpress With MySql on Windows Server 2012 R2
     インスタンスタイプ:t2.micro
     ストレージ:30GiB,SSD
     セキュリティグループ:RDP=マイIP
     キーペア:新しいキーペアの作成
      保存先:C:\user{yourusername}.ssh\MyFirstKey.pem
     セキュリティグループ
      インバウンドにルールを追加する
       TCP、8080、xxx.xxx.xxx.xxx/20 固定
       TCP、8080、yyy.yyy.yyy.yyy/32 変更されるごとに更新

    ・ホストを公開
     Elastic IPの取得、割り当て
      EC2ダッシュボード、Elastic IP、新しいアドレスの割り当て、アクション―アドレスの関連付け
     Elastic IPは関連付けたインスタンスが実行中でないと課金される

    ・squid
     https://wiki.squid-cache.org/KnowledgeBase/Windows#Squid-3.5 からインストール

     squid.confの編集
      acl localnet src xxx.xxx.xxx.xxx/20 # EC2 Private IP
      acl localnet src yyy.yyy.yyy.yyy/32 # PPPoE グローバルIP
      http_port 8080
      logformat squid %tl %6tr %>a %Ss/%03>Hs %

     Windowsファイアウォールにてsquis.exeにTCPプロトコルの8080ポートを開けた入力規則を追加する

  • あわれな

    トップニュ-スになるはずだった核問題が射撃問題で転落