티스토리 뷰
본 포스팅에서는 WildFly와 Apache 연동 가이드에 대해 살펴보겠습니다.
대표적인 오픈소스 소프트웨어 WAS WildFly와 WEB Apache는 최근 다양한 이유로 인해 많은 고객사의 선택을 받고 있습니다. 이로 인해 오픈소스에 대한 컨트롤 능력을 향상 시키기 위한 자료로서 WildFly와 Apache에 대해 기본부터 하나씩 살펴보고자 합니다.
Apache HTTPD Server 연동 설정
먼저 살펴볼 내용은 Apache 연동 설정입니다.
1. Apache HTTPD Server 설정
Apache HTTPD Server(이하 httpd) 설정은 httpd.conf, httpd-mpm.conf, httpd-info.conf, httpd-vhost.conf, httpd-default.conf, httpd-jk.conf, workers.properties, uriworkermap.properties를 수정합니다.
- mpm 프로세스 설정을 위한 httpd-mpm.conf
- 아파치 웹서버 상태 및 상황 확인을 위한 httpd-info.conf
- 가상호스트(virtualhost) 설정을 위한 httpd-vhost.conf
- 기본 설정을 포함하는 httpd-default.conf
- mod_jk 로딩을 위한 httpd-jk.conf
- 백엔드 was와의 연동 설정을 위한 workers.properties
- 백엔드 was로 포워딩할 uri 정보를 정의하는 uriworkermap.properties
1) httpd.conf
httpd.conf는 httpd의 주요 설정이 위치한 메인 설정 파일입니다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
...
...
Listen 80
...
...
# Server-pool management (MPM specific)
Include conf/extra/httpd-mpm.conf
# Real-time info on requests and configuration
Include conf/extra/httpd-info.conf
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
# Various default settings
Include conf/extra/httpd-default.conf
# Tomcat Connector settings
include conf/extra/httpd-jk.conf
|
설정해야 할 부분만 선별하여 작성하였습니다.
Listen Port는 80 port를 사용하며, 각 설정파일을 Include 하는 부분을 추가하였습니다.
2) httpd-mpm.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
#
# Server-Pool Management (MPM specific)
#
#
# PidFile: The file in which the server should record its process
# identification number when it starts.
#
# Note that this is the default PidFile for most MPMs.
#
<IfModule !mpm_netware_module>
PidFile "logs/httpd.pid"
</IfModule>
#
# Only one of the below sections will be relevant on your
# installed httpd. Use "apachectl -l" to find out the
# active mpm.
#
# prefork MPM
# StartServers: number of server processes to start
# MinSpareServers: minimum number of server processes which are kept spare
# MaxSpareServers: maximum number of server processes which are kept spare
# MaxRequestWorkers: maximum number of server processes allowed to start
# MaxConnectionsPerChild: maximum number of connections a server process serves
# before terminating
<IfModule mpm_prefork_module>
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxRequestWorkers 250
MaxConnectionsPerChild 0
</IfModule>
# worker MPM
# StartServers: initial number of server processes to start
# MinSpareThreads: minimum number of worker threads which are kept spare
# MaxSpareThreads: maximum number of worker threads which are kept spare
# ThreadsPerChild: constant number of worker threads in each server process
# MaxRequestWorkers: maximum number of worker threads
# MaxConnectionsPerChild: maximum number of connections a server process serves
# before terminating
<IfModule mpm_worker_module>
StartServers 3
MinSpareThreads 75
MaxSpareThreads 250
ThreadsPerChild 25
MaxRequestWorkers 400
MaxConnectionsPerChild 0
</IfModule>
# event MPM
# StartServers: initial number of server processes to start
# MinSpareThreads: minimum number of worker threads which are kept spare
# MaxSpareThreads: maximum number of worker threads which are kept spare
# ThreadsPerChild: constant number of worker threads in each server process
# MaxRequestWorkers: maximum number of worker threads
# MaxConnectionsPerChild: maximum number of connections a server process serves
# before terminating
<IfModule mpm_event_module>
StartServers 3
MinSpareThreads 75
MaxSpareThreads 250
ThreadsPerChild 25
MaxRequestWorkers 400
MaxConnectionsPerChild 0
</IfModule>
# NetWare MPM
# ThreadStackSize: Stack size allocated for each worker thread
# StartThreads: Number of worker threads launched at server startup
# MinSpareThreads: Minimum number of idle threads, to handle request spikes
# MaxSpareThreads: Maximum number of idle threads
# MaxThreads: Maximum number of worker threads alive at the same time
# MaxConnectionsPerChild: Maximum number of connections a thread serves. It
# is recommended that the default value of 0 be set
# for this directive on NetWare. This will allow the
# thread to continue to service requests indefinitely.
<IfModule mpm_netware_module>
ThreadStackSize 65536
StartThreads 250
MinSpareThreads 25
MaxSpareThreads 250
MaxThreads 1000
MaxConnectionsPerChild 0
</IfModule>
# OS/2 MPM
# StartServers: Number of server processes to maintain
# MinSpareThreads: Minimum number of idle threads per process,
# to handle request spikes
# MaxSpareThreads: Maximum number of idle threads per process
# MaxConnectionsPerChild: Maximum number of connections per server process
<IfModule mpm_mpmt_os2_module>
StartServers 2
MinSpareThreads 5
MaxSpareThreads 10
MaxConnectionsPerChild 0
</IfModule>
# WinNT MPM
# ThreadsPerChild: constant number of worker threads in the server process
# MaxConnectionsPerChild: maximum number of connections a server process serves
<IfModule mpm_winnt_module>
ThreadsPerChild 150
MaxConnectionsPerChild 0
</IfModule>
# The maximum number of free Kbytes that every allocator is allowed
# to hold without calling free(). In threaded MPMs, every thread has its own
# allocator. When not set, or when set to zero, the threshold will be set to
# unlimited.
<IfModule !mpm_netware_module>
MaxMemFree 2048
</IfModule>
<IfModule mpm_netware_module>
MaxMemFree 100
</IfModule>
|
cs |
프로세스 처리 방식에 대한 mpm 방식을 설정합니다.
3) httpd-info.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#
# Get information about the requests being processed by the server
# and the configuration of the server.
#
# Required modules: mod_authz_core, mod_authz_host,
# mod_info (for the server-info handler),
# mod_status (for the server-status handler)
#
# Allow server status reports generated by mod_status,
# with the URL of http://servername/server-status
# Change the ".example.com" to match your domain to enable.
<Location /server-status>
SetHandler server-status
Require host .example.com
Require ip 127
</Location>
#
# ExtendedStatus controls whether Apache will generate "full" status
# information (ExtendedStatus On) or just basic information (ExtendedStatus
# Off) when the "server-status" handler is called. The default is Off.
#
#ExtendedStatus On
#
# Allow remote server configuration reports, with the URL of
# http://servername/server-info (requires that mod_info.c be loaded).
# Change the ".example.com" to match your domain to enable.
#
<Location /server-info>
SetHandler server-info
Require host .example.com
Require ip 127
</Location>
|
cs |
서버의 정보와 상태를 확인하기 위한 status를 확인합니다. 상태를 확인하기 위해서는 *.example.com 또는 127로 시작하는 ip로 접속해야 하며, /server-status, /server-info로 확인할 수 있습니다.
4) httpd-vhost.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "/home/apache/httpd-2.4.25/htdocs"
ServerName api.portal.go.kr
ServerAlias testapi.portal.go.kr
ErrorLog "logs/api/api-error_log"
CustomLog "logs/api/api-access_log" common
JkMount /* mnt_oss_lb1
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "/home/apache/httpd-2.4.25/htdocs"
ServerName test.portal.go.kr
ServerAlias testportal.portal.go.kr
ErrorLog "logs/test/test-error_log"
CustomLog "logs/test/test-access_log" common
JkMount /* mnt_oss_lb2
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "/home/apache/httpd-2.4.25/htdocs"
ServerName hi.portal.go.kr
ServerAlias hiportal.portal.go.kr
ErrorLog "logs/hi/hi-error_log"
CustomLog "logs/hi/hi-access_log" common
JkMount /* mnt_oss_lb3
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "/home/apache/httpd-2.4.25/htdocs"
ServerName meta.portal.go.kr
ServerAlias metaportal.portal.go.kr
ErrorLog "logs/meta/meta-error_log"
CustomLog "logs/meta/meta-access_log" common
JkMount /* mnt_oss_lb4
</VirtualHost>
|
cs |
다양한 가상호스트를 등록하기 위한 설정입니다. 가상호스트는 총 4개가 등록되어 있으며, 각각 JkMount로 workers.properties의 work.list와 맵핑됩니다.
5) httpd-default.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
#
# Timeout: The number of seconds before receives and sends time out.
#
Timeout 60
#
# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
#
KeepAlive On
#
# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
#
MaxKeepAliveRequests 100
#
# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.
#
KeepAliveTimeout 5
#
# UseCanonicalName: Determines how Apache constructs self-referencing
# URLs and the SERVER_NAME and SERVER_PORT variables.
# When set "Off", Apache will use the Hostname and Port supplied
# by the client. When set "On", Apache will use the value of the
# ServerName directive.
#
UseCanonicalName Off
#
# AccessFileName: The name of the file to look for in each directory
# for additional configuration directives. See also the AllowOverride
# directive.
#
AccessFileName .htaccess
#
# ServerTokens
# This directive configures what you return as the Server HTTP response
# Header. The default is 'Full' which sends information about the OS-Type
# and compiled in modules.
# Set to one of: Full | OS | Minor | Minimal | Major | Prod
# where Full conveys the most information, and Prod the least.
#
ServerTokens Full
#
# Optionally add a line containing the server version and virtual host
# name to server-generated pages (internal error documents, FTP directory
# listings, mod_status and mod_info output etc., but not CGI generated
# documents or custom error documents).
# Set to "EMail" to also include a mailto: link to the ServerAdmin.
# Set to one of: On | Off | EMail
#
ServerSignature Off
#
# HostnameLookups: Log the names of clients or just their IP addresses
# e.g., www.apache.org (on) or 204.62.129.132 (off).
# The default is off because it'd be overall better for the net if people
# had to knowingly turn this feature on, since enabling it means that
# each client request will result in AT LEAST one lookup request to the
# nameserver.
#
HostnameLookups Off
#
# Set a timeout for how long the client may take to send the request header
# and body.
# The default for the headers is header=20-40,MinRate=500, which means wait
# for the first byte of headers for 20 seconds. If some data arrives,
# increase the timeout corresponding to a data rate of 500 bytes/s, but not
# above 40 seconds.
# The default for the request body is body=20,MinRate=500, which is the same
# but has no upper limit for the timeout.
# To disable, set to header=0 body=0
#
<IfModule reqtimeout_module>
RequestReadTimeout header=20-40,MinRate=500 body=20,MinRate=500
</IfModule>
|
cs |
기본 지시자를 정의하는 설정파일입니다. 웹 서버 연결 정보와 Request, Response에 대한 정보를 정의합니다.
6) httpd-jk.conf
1
2
3
4
5
6
7
8
9
10
11
12
|
LoadModule jk_module modules/mod_jk.so
<IfModule mod_jk.c>
JkWorkersFile conf/extra/workers.properties
JkLogFile "|/home/apache/httpd-2.4.25/bin/rotatelogs /home/apache/httpd-2.4.25/logs/jk.log_%Y%m%d 86400 +540"
JkLogLevel info
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkShmFile logs/jk.shm
# JkMountFile conf/extra/uriworkermap.properties
# JkMount /* mnt_oss_lb
</IfModule>
|
cs |
백엔드 was와 연동하기 위한 mod_jk를 로딩하며, Jk 관련 설정이 포함되어 있습니다.
mod_jk는 https://archive.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/ 에서 다운로드 받을 수 있습니다.
7) workers.properties
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
#########################
### api configuration ###
#########################
# Load Balnacing Config
worker.list=mnt_oss_lb1
worker.mnt_oss_lb1.type=lb
worker.mnt_oss_lb1.balance_workers=apiportal1,apiportal2
worker.mnt_oss_lb1.sticky_session=1
# Tomcat Connection Config
worker.apiportal1.type=ajp13
worker.apiportal1.host=192.168.2.175
worker.apiportal1.port=8109
worker.apiportal1.lbfactor=1
worker.apiportal1.route=apiportal1
#worker.apiportal1.socket_timeout=10
#worker.apiportal1.socket_connect_timeout=100000
#worker.apiportal1.socket_keepalive=True
#worker.apiportal1.connect_timeout=100000
#worker.apiportal1.connection_pool_size=128
#worker.apiportal1.connection_pool_minsize=32
#worker.apiportal1.connection_pool_timeout=100000
worker.apiportal2.type=ajp13
worker.apiportal2.host=192.168.2.176
worker.apiportal2.port=8109
worker.apiportal2.lbfactor=1
worker.apiportal2.route=apiportal2
#worker.apiportal2.socket_timeout=10
#worker.apiportal2.socket_connect_timeout=100000
#worker.apiportal2.socket_keepalive=True
#worker.apiportal2.connect_timeout=100000
#worker.apiportal2.connection_pool_size=128
#worker.apiportal2.connection_pool_minsize=32
#worker.apiportal2.connection_pool_timeout=100000
#########################
### kaf configuration ###
#########################
# Load Balnacing Config
worker.list=mnt_oss_lb2
worker.mnt_oss_lb2.type=lb
worker.mnt_oss_lb2.balance_workers=testportal1,testportal2
worker.mnt_oss_lb2.sticky_session=1
# Tomcat Connection Config
worker.testportal1.type=ajp13
worker.testportal1.host=192.168.2.175
worker.testportal1.port=8209
worker.testportal1.lbfactor=1
worker.testportal1.route=testportal1
worker.testportal2.type=ajp13
worker.testportal2.host=192.168.2.176
worker.testportal2.port=8209
worker.testportal2.lbfactor=1
worker.testportal2.route=testportal2
###########################
### kdash configuration ###
###########################
# Load Balnacing Config
worker.list=mnt_oss_lb3
worker.mnt_oss_lb3.type=lb
worker.mnt_oss_lb3.balance_workers=hiportal1,hiportal2
worker.mnt_oss_lb3.sticky_session=1
# Tomcat Connection Config
worker.hiportal1.type=ajp13
worker.hiportal1.host=192.168.2.175
worker.hiportal1.port=8309
worker.hiportal1.lbfactor=1
worker.hiportal1.route=hiportal1
worker.hiportal2.type=ajp13
worker.hiportal2.host=192.168.2.176
worker.hiportal2.port=8309
worker.hiportal2.lbfactor=1
worker.hiportal2.route=hiportal2
##########################
### meta configuration ###
##########################
# Load Balnacing Config
worker.list=mnt_oss_lb4
worker.mnt_oss_lb4.type=lb
worker.mnt_oss_lb4.balance_workers=metaportal1,metaportal2
worker.mnt_oss_lb4.sticky_session=1
# Tomcat Connection Config
worker.metaportal1.type=ajp13
worker.metaportal1.host=192.168.2.175
worker.metaportal1.port=8409
worker.metaportal1.lbfactor=1
worker.metaportal1.route=metaportal1
worker.metaportal2.type=ajp13
worker.metaportal2.host=192.168.2.176
worker.metaportal2.port=8409
worker.metaportal2.lbfactor=1
worker.metaportal2.route=metaportal2
|
cs |
백엔드와 연동하기 위한 설정파일이 포함되어 있습니다. 총 4개의 worker.list가 포함되어 있으며, 각각 httpd-vhost.conf의 JkMount 정보와 맵핑됩니다. 또한 Sticky Session을 사용하기 위한 sticky_session 및 route 정보가 포함되어 있습니다.
8) uriworkermap.properties
1
2
3
4
5
6
7
8
|
# Types defined under this line will be managed by tomcat server
/*=mnt_oss_lb
/*.do=mnt_oss_lb
/*.ajax=mnt_oss_lb
/*.jsp=mnt_oss_lb
/*.json=mnt_oss_lb
/*.jspf=mnt_oss_lb
/*.jsonp=mnt_oss_lb
|
cs |
백엔드로 포워딩 할 uri 정보가 포함되어 있습니다. /*=mnt_oss_lb의 경우 전체를 WAS로 포워딩하는 설정입니다.
'④ 미들웨어 > ⓦ WildFly' 카테고리의 다른 글
[WildFly] Apache HTTPD Server 연동 가이드 (2/2) (0) | 2019.09.19 |
---|---|
[WildFly] 다양한 Shell Script (0) | 2019.09.17 |
[WildFly] 오픈소스 APM Scouter 설치 및 연동 (0) | 2019.01.03 |
[WildFly] 외부캐시 서버와의 연동을 통한 세션 클러스터링 테스트 (0) | 2018.10.24 |
[WildFly] database연동방식 (Thin,OCI) (0) | 2018.09.27 |
- Total
- Today
- Yesterday
- 아키텍처
- Docker
- SWA
- aa
- aws
- 마이크로서비스
- TA
- webtob
- apache
- API Gateway
- JEUS6
- jeus
- git
- JBoss
- Da
- SA
- Architecture
- 오픈스택
- OpenStack
- openstack token issue
- 쿠버네티스
- JEUS7
- node.js
- 마이크로서비스 아키텍처
- nodejs
- wildfly
- openstack tenant
- k8s
- MSA
- kubernetes
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |