curlでHEADリクエスト

表題の通り。やりたい案件があったので調べた。

■ 環境

  • curl

■ HEAD

HTTPでアクセスし、BODYはいらないのだがHEADを確認したい。というのでhelpを確認したところ下記のオプションがあったので試してみた。

$ curl -h
  :
 -I, --head          Show document info only
  :
$

実際に試してみる。

$ curl -I https://www.google.co.jp/
HTTP/1.1 200 OK
Date: Tue, 31 Aug 2016 10:10:54 GMT
Expires: -1
Cache-Control: private, max-age=0
Content-Type: text/html; charset=Shift_JIS
P3P: CP="This is not a P3P policy! See https://www.google.com/support/accounts/answer/151657?hl=en for more info."
Server: gws
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
Set-Cookie: NID=85=XXXXKvPBXXvYBVXXXNkveXXxw0d9XXVXap3rxxXX8XX3GEZ2n8hXnOx2GvAL-a6p8hOrsHrjIi2kXuSAuc3nr79Wx48ZEp4iBa5svVY62mOb43nOD_ArtEneE29E-UN; expires=Wed, 01-Mar-2017 09:27:54 GMT; path=/; domain=.google.co.jp; HttpOnly
Alternate-Protocol: 443:quic
Alt-Svc: quic=":443"; ma=2592000; v="36,35,34,33,32,31,30"
Transfer-Encoding: chunked
Accept-Ranges: none
Vary: Accept-Encoding

$

これでやりたい事ができそうである。

ちなみにWebサーバ側のログには下記のように出ていた。アクセス先は自身が見る事ができるホストに変えて行ってみた場合である。

XXX.XXX.XXX.XXX - - [31/Aug/2016:19:11:52 +0900] "HEAD / HTTP/1.1" 200 0 "-" "curl/7.43.0"

以上。

稼働中のElasticsearchのversion

表題の通り。

■ 環境

  • Elasticsearch 2.3.5
  • Docker for Mac 1.12.0-a
  • Mac OSX El Capitan

■ Elasticsearch

Dockerで稼働しているElasticsearchに対して下記コマンドを実行してみた。

$ curl http://localhost:9200/
{
  "name" : "Screaming Mimi",
  "cluster_name" : "elasticsearch_withsin",
  "version" : {
    "number" : "2.3.5",
    "build_hash" : "90f439ff60a3c0f497f91663701e64ccd01edbb4",
    "build_timestamp" : "2016-07-27T10:36:52Z",
    "build_snapshot" : false,
    "lucene_version" : "5.5.0"
  },
  "tagline" : "You Know, for Search"
}
$

ここから稼働中のElasticsearchのversionが確認できる。

ちなみにDockerにおけるElasticsearchは下記で稼働をさせている。

$ docker pull elasticsearch
$ docker run -d elasticsearch

以上。

■ 関連

Amazon LinuxにElasticsearchをyum install

表題の通り。以前はソースからインストールしたが今回はパッケージでインストールする。

■ 環境

  • Elasticsearch 2.3.5
  • Amazon Linux

■ install

公式のドキュメントにあるまま。

Elasticsearch Reference [2.3] > Setup > Repositories
https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-repositories.html

インストール対象がAmazon Linuxなので”YUM/DNF“を参照する。

$ sudo rpm --import https://packages.elastic.co/GPG-KEY-elasticsearch

`/etc/yum.repos.d/elasticsearch.repo`に下記を記述する。

[elasticsearch-2.x]
name=Elasticsearch repository for 2.x packages
baseurl=https://packages.elastic.co/elasticsearch/2.x/centos
gpgcheck=1
gpgkey=https://packages.elastic.co/GPG-KEY-elasticsearch
enabled=1

あとはインストール。

$ sudo yum update
$ sudo yum install elasticsearch

■ start

Macで入れたような`elasticsearch`コマンドは存在しない。`service`コマンドで起動する。

$ sudo service elasticsearch start
Starting elasticsearch:                        [  OK  ]
$

以上。

■ 関連

  • AmazonLinuxでElasticsearchを稼働

Elasticsearchコンテナのversion確認

Dockerにおいて表題の通り。Elasticsearchの”latest“で稼働しているコンテナがあるのだが、Elasticsearchのどのversionが動いているのかを知りたい。

■ 環境

  • Elasticsearch 2.3.4
  • Docker for Mac 1.12.0-a
  • Mac OSX El Capitan

■ version

Elasticsearch側からも知る方法があるであろうが、今回はDocker側からのアプローチを試みる。何か情報となるところはないかと思っていたのだが、稼働させているコンテナの下記を確認したところ情報が得られた。下記は”elasticsearch“という名前を付けて起動しているコンテナに対して行なっている。

$ docker inspect elasticsearch
[
    {
        "Id": "fe28ad03be38e42c1ba3cf4500b0425030d5e49a6bf1bd7aac5cbf781934dd4b",
  :
            "Env": [
                "no_proxy=*.local, 169.254/16",
                "PATH=/usr/share/elasticsearch/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "LANG=C.UTF-8",
                "JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre",
                "JAVA_VERSION=8u91",
                "JAVA_DEBIAN_VERSION=8u91-b14-1~bpo8+1",
                "CA_CERTIFICATES_JAVA_VERSION=20140324",
                "GOSU_VERSION=1.7",
                "ELASTICSEARCH_VERSION=2.3.4",
                "ELASTICSEARCH_REPO_BASE=http://packages.elasticsearch.org/elasticsearch/2.x/debian"
            ],
  :
$

環境変数にJavaのversionやElasticsearchのversionが入っていた。

Elasticsearchの最新versionは”2.3.5“が既にリリースされているはずであるから、現在”latest“を`docker pull`すれば、”ELASTICSEARCH_VERSION=2.3.5“のコンテナが稼働していることであろう。

以上。

■ 関連

nginxコンテナのDockerfile

表題の通り。

■ 環境

  • nginx
  • Docker for Mac 1.12.0-a
  • Mac OSX El Capitan

■ Dockerfile

nginxがどのようにコンパイル等されているのかと思ってDockerfileを確認しようと思った。

nginx – DockerHub
https://hub.docker.com/r/library/nginx/

ここから現状の”latest“リンクから確認すると、`apt−get`でパッケージをインストールしている。

  • nginx
  • nginx-module-geoip
  • nginx-module-image-filter
  • nginx-module-njs
  • nginx-module-perl
  • nginx-module-xslt

これらがインストールされていた。これだと先日のコンパイルオプションを変えたいなとなると、そう簡単にはいかない。。

ちなみに”alpine“のDockerfileを確認すると、Alpineのパッケージには存在しないのであろう、ソースコンパイルを行っていた。`configure`のオプションは下記のようである。

--prefix=/etc/nginx \
--sbin-path=/usr/sbin/nginx \
--modules-path=/usr/lib/nginx/modules \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--http-client-body-temp-path=/var/cache/nginx/client_temp \
--http-proxy-temp-path=/var/cache/nginx/proxy_temp \
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \
--http-scgi-temp-path=/var/cache/nginx/scgi_temp \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--with-http_auth_request_module \
--with-http_xslt_module=dynamic \
--with-http_image_filter_module=dynamic \
--with-http_geoip_module=dynamic \
--with-http_perl_module=dynamic \
--with-threads \
--with-stream \
--with-stream_ssl_module \
--with-stream_geoip_module=dynamic \
--with-http_slice_module \
--with-mail \
--with-mail_ssl_module \
--with-file-aio \
--with-http_v2_module \
--with-ipv6 \

先日のものと少しオプションが違うようだ。

以上。

■ 関連