比較バージョン

キー

  • この行は追加されました。
  • この行は削除されました。
  • 書式設定が変更されました。

...

2. Java 11(OpenJDK)をインストールする

...


1. インストール


CentOS 7にはOpenJDKのパッケージが用意されていますので、これをyumにてインストールします。

...

アンカー
seminar-idpInst3
seminar-idpInst3

3. Jetty 9.4 をインストールする

1. インストール

CentOS 7にはJettyのパッケージがないので、ダウンロードしてインストールします。
実習セミナーでは予めダウンロードした「/root/PKG」内の、jetty-distribution-9.4.*.v????????.tar.gz を使います。
さらに、Shibboleth Projectが配布している各種設定ファイル群(jetty-base)を配置します。
こちらも予め「/root/PKG」内に配置してあるものを使用します。

...

パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

# sudo cp -ip /opt/jetty/bin/jetty.sh /etc/init.d/jetty
# sudo cp -ip /opt/jetty/bin/jetty.service /etc/systemd/system/

...

パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

# sudo systemctl daemon-reload

以下の内容で/etc/sysconfig/jettyを作成します。

...

パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

# systemctl enable jetty

補足:
以下のコマンドで自動起動設定を無効にすることができます。
# systemctl disable jetty


3. jetty-baseの設定 

以下のように関連する設定ファイルの作成や修正を行っていきます。以下のように関連する設定ファイルの作成や修正を行います。

/opt/jetty-base/webapps/idp.xmlの修正xml の修正
パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="war"><SystemProperty name="idp.war.path" default="/opt/shibboleth-idp/war/idp.war" /></Set>
<Set name="contextPath"><SystemProperty name="idp.context.path" default="/idp" /></Set>
<Set name="extractWAR">false</Set>
<Set name="copyWebDir">false</Set>
<Set name="copyWebInf">true</Set>
</Configure>

/opt/jetty-base/start.d/idp-backchannel.

...

ini を無効化
パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

# sudo mv # mv -i /opt/jetty-base/start.d/idp-backchannel.ini /opt/jetty-base/start.d/idp-backchannel.ini.dist

/opt/jetty-base/start.d/start.iniの作成
ini の作成
パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

# Any other required Jetty

コード ブロック
languagebash
# Any other required Jetty

modules...

#

Allows

setting

Java

system

properties

(-Dname=value)

#

and

JVM

flags

(-X,

-XX)

in

this

file

#

NOTE:

spawns

child

Java

process

--exec

#

Uncomment

if

IdP

is

installed

somewhere

other

than

/opt/shibboleth-idp

#-Didp.home=/path/to/shibboleth-idp

#

Newer

garbage

collector

that

reduces

memory

needed

for

larger

metadata

files

-XX:+UseG1GC

#

Maximum

amount

of

memory

that

Jetty

may

use,

at

least

1.5G

is

recommended

#

for

handling

larger

(>

25M)

metadata

files

but

you

will

need

to

test

on

#

your

particular

metadata

configuration

-Xmx1500m

#

Prevent

blocking

for

entropy.

-Djava.security.egd=file:/dev/./urandom

#

Set

Java

tmp

location

-Djava.io.tmpdir=tmp

#

Strip

IPv6

brackets

#-Dorg.eclipse.jetty.util.HostPort.STRIP_IPV6=true

パネル
/opt/jetty-base/start.d/idp.ini の修正
パネル
borderColor#cccccc
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

# sudo mv -i /opt/jetty-base/start.d/idp-backchannel.ini /opt/jetty-base/start.d/idp-backchannel.ini.dist

コード ブロック
languagebash
#JAVA_OPTS="-Xminf0.1 -Xmaxf0.3"
JAVA_OPTS="-server -Xmx1500m -XX:MaxPermSize=256m -XX:+UseG1GC "

...

/opt/jetty-base/webapps/idp.xmlを以下のように修正します。(idp.warファイルのパス修正)

コード ブロック
languagebash
# /etc/profile.d/java-tomcat.sh - set Java and Tomcat stuff
JAVA_HOME=/usr/lib/jvm/java
#export MANPATH=$MANPATH:/usr/java/default/man
CATALINA_HOME=/usr/share/tomcat
CATALINA_BASE=$CATALINA_HOME
PATH=$JAVA_HOME/bin:$CATALINA_BASE/bin:$CATALINA_HOME/bin:$PATH
export PATH JAVA_HOME CATALINA_HOME CATALINA_BASE

追加した環境変数を読み込みます。

パネル
bgColor#eeeeee

# source /etc/profile

5. Apache の設定

...

# ---------------------------------------
# Module: idp
# Shibboleth IdP
# ---------------------------------------
--module=idp
--module=http
--module=http-forwarded

## Keystore file path (relative to $jetty.base)
jetty.sslContext.keyStorePath=../credentials/idp-userfacing.p12


(省略)

※末尾に以下を追加

## Connector port to listen on
jetty.ssl.port=443  ※利用されない
jetty.http.host=127.0.0.1
jetty.http.port=8080

/opt/jetty-base/modules/idp.mod の修正
パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

(省略)
#ServerName ex-idp-test??.gakunin.nii.ac.jp:80 ← ??は各自割り振られた番番号(0番なら「00」
↑コメントアウト(#)を削除
(省略)

...

[depend]
annotations
deploy
ext
#https
jsp
jstl
plus
resources
server
servlets
#ssl

/opt/jetty-base/etc/tweak-ssl.xml の作成
パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

(省略)
<VirtualHost _default_:443>

(省略)
#ServerName ex-idp-test??.gakunin.nii.ac.jp:443 ← ??は各自割り振られた番号(0番なら「00」
↑コメントアウト(#)を削除
ProxyPass /idp/ ajp://localhost:8009/idp/ ← 設定を追加
(省略)

6. Tomcat の設定

以下の内容で /etc/httpd/conf.d/virtualhost-localhost80.conf を作成します。

これはShibboleth IdPが提供するreload-metadata.sh等のコマンドを使った操作を可能にするためのものです。

パネル
bgColor#eeeeee
<VirtualHost localhost:80>
ProxyPass /idp/ ajp://localhost:8009/idp/
</VirtualHost>

以下のように /usr/share/tomcat/conf/server.xml を修正します。

※実習環境では、Connector port="8080" をコメントアウトします。

パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid
<!--
    <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
-->

※Connector port="8009"に以下のように追加してください。

<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN"
"http://www.eclipse.org/jetty/configure_9_4.dtd">
<Configure id="sslContextFactory" class="org.eclipse.jetty.util.ssl.SslContextFactory">
<Set name="IncludeProtocols">
<Array type="String">
<Item>TLSv1.3</Item>
<Item>TLSv1.2</Item>
</Array>
</Set>
<Set name="ExcludeProtocols">
<Array type="String">
<Item>TLSv1.1</Item>
<Item>TLSv1</Item>
<Item>SSL</Item>
<Item>SSLv2</Item>
<Item>SSLv3</Item>
</Array>
</Set>
<Set name="IncludeCipherSuites">
<Array type="String">
<Item>TLS_ECDHE.*</Item>
<Item>TLS_AES.*</Item>
<Item>TLS_RSA.*</Item>
</Array>
</Set>
<Set name="ExcludeCipherSuites">
<Array type="String">
<Item>.*NULL.*</Item>
<Item>.*RC4.*</Item>
<Item>.*MD5.*</Item>
<Item>.*DES.*</Item>
<Item>.*DSS.*</Item>
<Item>TLS_DHE.*</Item>
</Array>
</Set>
</Configure>


4. httpd の設定

以下のように設定ファイルの修正を行います。


/etc/httpd/conf/httpd.conf の修正
パネル
borderColor
パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

<!-- Define an AJP 1.3 Connector on port 8009 -->
<!--
<Connector protocol="AJP/1.3"
address="::1"
port="8009"
redirectPort="8443" />
-->

<Connector port="8009" protocol="AJP/1.3" redirectPort="8443"
           secretRequired="false" enableLookups="false" tomcatAuthentication="false" address="127.0.0.1" maxPostSize="100000" />

...

4. Shibbolethのインストール 

各ファイル名等の指定は,Version 4.0.1に準拠しています。

1.   インストール

Shibboleth IdPのパッケージは、「/root/PKG」配下にあります。

以下のコマンドで移動してください。

パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid
# cd /root/PKG

 shibboleth-identity-provider-4.?.?.tar.gz がすでに配置されているので、以下のコマンドを実行してください。

パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

# tar xzvf shibboleth-identity-provider-4.?.?.tar.gz
# cd shibboleth-identity-provider-4.?.?
# ./bin/install.sh -Didp.conf.filemode=640

 install.shシェルスクリプトを実行すると、以下のような問い合わせがあります。
手順に従って、進めてください。

...

(省略)
#ServerName ex-idp-test??.gakunin.nii.ac.jp:80 ← ??は各自割り振られた番番号(0番なら「00」
↑コメントアウト(#)を削除
(省略)

/etc/httpd/conf.d/ssl.conf の修正
パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

(省略)
<VirtualHost _default_:443>

(省略)
#ServerName ex-idp-test??.gakunin.nii.ac.jp:443 ← ??は各自割り振られた番号(0番なら「00」
↑コメントアウト(#)を削除
↓以下を追加
RequestHeader set X-Forwarded-Port 443
RequestHeader set X-Forwarded-Proto https

ProxyPass /idp/ http://localhost:8080/idp/ connectiontimeout=5 timeout=15
RequestHeader set REMOTE-USER %{REMOTE_USER}s

(省略)

/etc/httpd/conf.d/virtualhost-localhost80.conf の作成

これはShibboleth IdPが提供するreload-metadata.sh等のコマンドを使った操作を可能にするためのものです。

パネル
bgColor#eeeeee

<VirtualHost localhost:80>
ProxyPass /idp/ http://localhost:8080/idp/ connectiontimeout=5 timeout=15
</VirtualHost>


...

アンカー
idpInst4
idpInst4

4. Shibbolethのインストール 

各ファイル名等の指定は,Version 4.0.1に準拠しています。

1.   インストール

Shibboleth IdPのパッケージは、「/root/PKG」配下にあります。

以下のコマンドで移動してください。

...

パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid
Buildfile: # cd /root/PKG/shibboleth

 shibboleth-identity-provider-4.?.?.tar.gz がすでに配置されているので、以下のコマンドを実行してください。

パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

# tar xzvf 0.1/bin/build.xml
install:
Source (Distribution) Directory (press <enter> to accept default): [/root/PKG/ shibboleth-identity-provider-4.0?.1] ?
[Enter] ←入力なし

Installation Directory: [/opt/shibboleth-idp]
[Enter] ←入力なし
Hostname: [ex-idp-test??.gakunin.nii.ac.jp]

[Enter] 入力なし ※表示されたホスト名が違う場合、設定してください。
Backchannel PKCS12 Password: backpass[Enter] ←任意のパスワード

Re-enter password: backpass[Enter]

Cookie Encryption Key Password: cookiepass[Enter] ←任意のパスワード
Re-enter password: cookiepass[Enter]
SAML EntityID: [https://ex-idp-test??.gakunin.nii.ac.jp/idp/shibboleth]
[Enter] ←入力なし
Attribute Scope: [
gakunin.nii.ac.jp]
nii.ac.jp [Enter] nii.ac.jpを設定してください。

 (省略)

BUILD SUCCESSFUL
Total time: 2 minutes 9 seconds

...

.tar.gz
# cd shibboleth-identity-provider-4.?.?
# ./bin/install.sh -Didp.conf.filemode=640

 install.shシェルスクリプトを実行すると、以下のような問い合わせがあります。
手順に従って、進めてください。

注意

インストール時に入力するパスワードを本運用で使う場合は、推測されにくいものを使用してください。
※ここで入力したパスワードは、/opt/shibboleth-idp/conf/idp.propertiesに記載されます。(平文)

パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

Buildfile: /root/PKG/shibboleth-identity-provider-4.0.1/bin/build.xml

install:
Source (Distribution) Directory (press <enter> to accept default): [/root/PKG/shibboleth-identity-provider-4.0.1] ?
[Enter] ←入力なし

Installation Directory: [/opt/shibboleth-idp] ?
[Enter] ←入力なし
INFO [net.shibboleth.idp.installer.V4Install:151] - New Install. Version: 4.0.1
Hostname: [ex-idp-test??.gakunin.nii.ac.jp]

[Enter] 入力なし ※表示されたホスト名が違う場合、設定してください。
 (省略)
Backchannel PKCS12 Password: backpass[Enter] ←任意のパスワード

Re-enter password: backpass[Enter]

 (省略)
Cookie Encryption Key Password: cookiepass[Enter] ←任意のパスワード
Re-enter password: cookiepass[Enter]
 (省略)
SAML EntityID: [https://
ex-idp-test??.gakunin.nii.ac.jp/idp/shibboleth] ?
[Enter] ←入力なし
Attribute Scope: [
gakunin.nii.ac.jp]
nii.ac.jp [Enter] nii.ac.jpを設定してください。

 (省略)

BUILD SUCCESSFUL
Total time: 2 minutes 9 seconds

 上記のような質問に答えながら、インストールを行います。

2. パーミッションの調整 

Jettyは、”jetty”ユーザで実行しているので、ログファイルを出力できるようディレクトリの所有者を変更します。
同様に、設定ファイルやメタデータの保存ディレクトリなどの所有者・パーミッションも変更します。

パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

# chown -R jetty:jetty /opt/shibboleth-idp/logs
# chgrp jetty /opt/shibboleth-idp/metadata
# chmod g+w /opt/shibboleth-idp/metadata
# chmod +t /opt/shibboleth-idp/metadata

2. パーミッションの調整 

Tomcatを”tomcat”ユーザで実行する場合は、ログファイルを出力できるようディレクトリの所有者を変更します。
同様に、設定ファイルやメタデータの保存ディレクトリなどの所有者・パーミッションも変更します。

注意

ここで設定したパーミッションをShibboleth IdPアップデート時に変更されないよう注意が必要です。詳細は IdPv3アップデートに関する情報 をご参照ください。

パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid
# chown -R tomcat:tomcat /opt/shibboleth-idp/logs
# chgrp -R tomcat /opt/shibboleth-idp/conf
# chmod -R g+r /opt/shibboleth-idp/conf
# find /opt/shibboleth-idp/conf -type d -exec chmod -R g+s {} \;
# chgrp tomcat /opt/shibboleth-idp/metadata
# chmod g+w /opt/shibboleth-idp/metadata
# chmod +t /opt/shibboleth-idp/metadata
# chgrp tomcat /opt/shibboleth-idp/credentials/secrets.properties
# chmod g+r /opt/shibboleth-idp/credentials/secrets.properties
# chgrp tomcat /opt/shibboleth-idp/credentials/sealer.*
# chmod g+r /opt/shibboleth-idp/credentials/sealer.*

ヒント

IdPが実際に使用する証明書の秘密鍵はまだ配置されておりませんので、所有者・パーミッションは後の手順で設定します。

...

アンカー
jakarta-taglibs-core.jar_jakarta-taglibs-standard.jar
jakarta-taglibs-core.jar_jakarta-taglibs-standard.jar

3jstl-1.2.jar の配置 

 jstl-1.2.jarは、予め「/root/PKG」配下にあります。※jstlの別途インストールは不要



4. ディレクトリインデックスの禁止

edit-webapp/ 配下に配置し、idp.warに含めます。webapp内にweb.xml を作成します。



パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

#

cp /root/PKG/jstl-1.2.jar

cp -ip /opt/shibboleth-idp/dist/webapp/WEB-INF/web.xml /opt/shibboleth-idp/edit-webapp/WEB-INF/

lib/
#

web.xml
# chmod u+w /opt/shibboleth-idp

/bin/build.sh
Installation Directory: [/opt/shibboleth-idp]
[Enter] ←入力なし
Rebuilding /opt/shibboleth-idp/war/idp.war ...
...done
BUILD SUCCESSFUL
Total time: 3 seconds

4. idp.war の登録 

...

/edit-webapp/WEB-INF/web.xml


作成したweb.xml を以下の内容で修正します。
※既存の<servlet>の前に設定を追加します。

パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

<filter-mapping>
<filter-name>SLF4JMDCServletFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<!-- Servlets and servlet mappings -->
<servlet>
<servlet-name>default</servlet-name>
<servlet-class>org.eclipse.jetty.servlet.DefaultServlet</servlet-class>
<init-param>
<param-name>dirAllowed</param-name>
<param-value>false</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>

<servlet>
<servlet-name>idp</servlet-name>

以下を実行して反映させます。

パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid

<Context docBase="# cp -ip /opt/shibboleth-idp/war/idp.war"
         privileged="true"
         antiResourceLocking="false"
         swallowOutput="true">
    <Manager pathname="" />
    <!-- Work around lack of Max-Age support in IE/Edge -->
    <CookieProcessor alwaysAddExpires="true" />
</Context>

 httpdの再起動とTomcatの起動を行います。(すでにTomcatが起動している場合はstopしてから行ってください)

パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid
# systemctl restart httpd
# systemctl start tomcat

Tomcatの起動後、${CATALINA_BASE}/logs/catalina.{日付}.logにエラーが出力されていない事を確認してください。

ヒント
titleヒント

※catalina.{日付}.logにTomcat終了時(再起動時)のタイミングで以下のようなエラーが表示されることがありますが問題ありませんので無視してください。

パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid
致命的: A web application appears to have started a TimerThread named [Timer-0] via the java.util.Timer API but has failed to stop it. To prevent a memory leak, the timer (and hence the associated thread) has been forcibly cancelled.
パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid
致命的: A web application created a ThreadLocal with key of type [null] (value [ch.qos.logback.core.UnsynchronizedAppenderBase$1@XXXXXXXX]) and a value of type [java.lang.Boolean] (value [false]) but failed to remove it when the web application was stopped. To prevent a memory leak, the ThreadLocal has been forcibly removed.

(関連するバグレポート)

dist/webapp/WEB-INF/web.xml /opt/shibboleth-idp/edit-webapp/WEB-INF/web.xml
# chmod u+w /opt/shibboleth-idp/edit-webapp/WEB-INF/web.xml



httpdの再起動とJettyの起動を行います。(すでにJettyが起動している場合はstopしてから行ってください)

パネル
borderColor#cccccc
bgColor#eeeeee
borderStylesolid
# systemctl restart httpd
# systemctl start jetty
注意

※jetty起動に失敗したら設定修正後、/opt/jetty-base/tmp/下にファイルが残っていたら削除してから再度起動してください。
※build.shしたら sudo systemctl restart jetty しないと反映されません。


...

アンカー
idpInst5
idpInst5

5. サービスの起動・停止方法

サービス起動コマンド停止コマンド再起動コマンド
httpdsystemctl start httpdsystemctl stop httpdsystemctl restart httpd
tomcatjettysystemctl start tomcatjettysystemctl stop tomcatjettysystemctl restart tomcatjetty


...

インストールが完了したら,サイト情報等の設定を行って下さい.

...

# sudo /opt/shibboleth-idp/bin/build.sh