環境 / 構成
* 例として、以下のURLのWebサービスが、以下の構成されているシステムを考えるURL : https://www.example.com/SampleWebService/
* Client | HTTPS ↓ * ELB(ロードバランサ) | HTTP ↓ * Nginx | HTTP ↓ * Tomcat (v8.5.11) ↓ * Webサービス
前提
* ELB の設定は行っていること * Nginx、Tomcat のインストールはしてあることNginx
http://blogs.yahoo.co.jp/dk521123/36721709.html
Tomcat
http://blogs.yahoo.co.jp/dk521123/36706185.html
設定
Nginx / default.conf
sudo vi /etc/nginx/conf.d/default.confserver {
# ・・・略・・・
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
# ★ 追加 ★
location /SampleWebService/ {
proxy_http_version 1.1;
proxy_pass http://localhost:8080/SampleWebService/;
}
# ★ 追加/ヘルスチェックのため ★
location = /healthcheck.html {
empty_gif;
break;
}
# ・・・略・・・
}
Tomcat / server.xml
sudo vi /usr/local/tomcat/conf/server.xml<!-- Comment Out
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
-->
<Connector port="8080" protocol="HTTP/1.1"
proxyPort="443"
scheme="https"
secure="true"
proxyName="www.example.com"
URIEncoding="UTF-8"
connectionTimeout="20000"
redirectPort="8443" />
参考文献
https://willwarren.com/2014/01/27/running-apache-tomcat-with-ssl-behind-amazon-elb/Tomcatとの連携
http://qiita.com/nenokido2000/items/c369ec12c32c191356d8
http://sekai.hatenablog.jp/entry/2013/02/13/185900
health checkをする際に使える便利なempty_gif
http://qiita.com/yumiyon/items/5cd2c6b4c696355926dc
http://nginx.org/en/docs/http/ngx_http_empty_gif_module.html