업무에서는 nginx를 사용하기 이미 설치가 되어 있는 상태였으나 신규로 아파치를 설치하고 사용해야하는 일이 생겼다.

또한 추후 인터넷을 사용할 수 없는 상황에서 설치할 수 있기 때문에 이번에 패키지를 yum install 이 아닌 download 후 install 하는 방식으로 하고자한다.

 

1. 패키지 다운로드 (인터넷 되는 환경에서)

httpd 패키지 다운로드

sudo yum install --downloadonly --downloaddir=./ httpd

 

[ec2-user apache]$ sudo yum install --downloadonly --downloaddir=./ httpd
Updating Subscription Management repositories.
Unable to read consumer identity

This system is not registered with an entitlement server. You can use "rhc" or "subscription-manager" to register.

Last metadata expiration check: 0:02:41 ago on Mon 21 Apr 2025 03:12:48 PM KST.
Dependencies resolved.
============================================================================================================================================================================================================
 Package                                           Architecture                          Version                                            Repository                                                 Size
============================================================================================================================================================================================================
Installing:
 httpd                                             x86_64                                2.4.62-1.el9_5.2                                   rhel-9-appstream-rhui-rpms                                 51 k
Installing dependencies:
 apr                                               x86_64                                1.7.0-12.el9_3                                     rhel-9-appstream-rhui-rpms                                126 k
 apr-util                                          x86_64                                1.6.1-23.el9                                       rhel-9-appstream-rhui-rpms                                 97 k
 apr-util-bdb                                      x86_64                                1.6.1-23.el9                                       rhel-9-appstream-rhui-rpms                                 14 k
 httpd-core                                        x86_64                                2.4.62-1.el9_5.2                                   rhel-9-appstream-rhui-rpms                                1.5 M
 httpd-filesystem                                  noarch                                2.4.62-1.el9_5.2                                   rhel-9-appstream-rhui-rpms                                 15 k
 httpd-tools                                       x86_64                                2.4.62-1.el9_5.2                                   rhel-9-appstream-rhui-rpms                                 86 k
 mailcap                                           noarch                                2.1.49-5.el9                                       rhel-9-baseos-rhui-rpms                                    35 k
 redhat-logos-httpd                                noarch                                90.4-2.el9                                         rhel-9-appstream-rhui-rpms                                 18 k
Installing weak dependencies:
 apr-util-openssl                                  x86_64                                1.6.1-23.el9                                       rhel-9-appstream-rhui-rpms                                 17 k
 mod_http2                                         x86_64                                2.0.26-2.el9_4.1                                   rhel-9-appstream-rhui-rpms                                167 k
 mod_lua                                           x86_64                                2.4.62-1.el9_5.2                                   rhel-9-appstream-rhui-rpms                                 60 k

Transaction Summary
============================================================================================================================================================================================================
Install  12 Packages

Total download size: 2.2 M
Installed size: 6.1 M
YUM will only download packages for the transaction.
Is this ok [y/N]: y
Downloading Packages:
(1/12): apr-util-openssl-1.6.1-23.el9.x86_64.rpm                                                                                                                            439 kB/s |  17 kB     00:00
(2/12): apr-util-bdb-1.6.1-23.el9.x86_64.rpm                                                                                                                                353 kB/s |  14 kB     00:00
(3/12): apr-util-1.6.1-23.el9.x86_64.rpm                                                                                                                                    2.1 MB/s |  97 kB     00:00
(4/12): redhat-logos-httpd-90.4-2.el9.noarch.rpm                                                                                                                            2.0 MB/s |  18 kB     00:00
(5/12): apr-1.7.0-12.el9_3.x86_64.rpm                                                                                                                                        11 MB/s | 126 kB     00:00
(6/12): mod_http2-2.0.26-2.el9_4.1.x86_64.rpm                                                                                                                                15 MB/s | 167 kB     00:00
(7/12): httpd-2.4.62-1.el9_5.2.x86_64.rpm                                                                                                                                   4.5 MB/s |  51 kB     00:00
(8/12): httpd-filesystem-2.4.62-1.el9_5.2.noarch.rpm                                                                                                                        2.7 MB/s |  15 kB     00:00
(9/12): httpd-tools-2.4.62-1.el9_5.2.x86_64.rpm                                                                                                                             7.1 MB/s |  86 kB     00:00
(10/12): mod_lua-2.4.62-1.el9_5.2.x86_64.rpm                                                                                                                                5.8 MB/s |  60 kB     00:00
(11/12): mailcap-2.1.49-5.el9.noarch.rpm                                                                                                                                    3.3 MB/s |  35 kB     00:00
(12/12): httpd-core-2.4.62-1.el9_5.2.x86_64.rpm                                                                                                                              35 MB/s | 1.5 MB     00:00
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                        16 MB/s | 2.2 MB     00:00
Complete!
The downloaded packages were saved in cache until the next successful transaction.
You can remove cached packages by executing 'yum clean packages'.
[ec2-user apache]$ ll
total 2280
drwxr-xr-x. 3 ec2-user ec2-user      21 Apr 21 14:06 '~'
-rw-r--r--. 1 root     root      129032 Apr 21 15:15  apr-1.7.0-12.el9_3.x86_64.rpm
-rw-r--r--. 1 root     root       99555 Apr 21 15:15  apr-util-1.6.1-23.el9.x86_64.rpm
-rw-r--r--. 1 root     root       14447 Apr 21 15:15  apr-util-bdb-1.6.1-23.el9.x86_64.rpm
-rw-r--r--. 1 root     root       16990 Apr 21 15:15  apr-util-openssl-1.6.1-23.el9.x86_64.rpm
-rw-r--r--. 1 root     root       52310 Apr 21 15:15  httpd-2.4.62-1.el9_5.2.x86_64.rpm
-rw-r--r--. 1 root     root     1602367 Apr 21 15:15  httpd-core-2.4.62-1.el9_5.2.x86_64.rpm
-rw-r--r--. 1 root     root       15487 Apr 21 15:15  httpd-filesystem-2.4.62-1.el9_5.2.noarch.rpm
-rw-r--r--. 1 root     root       88326 Apr 21 15:15  httpd-tools-2.4.62-1.el9_5.2.x86_64.rpm
-rw-r--r--. 1 root     root       35492 Apr 21 15:15  mailcap-2.1.49-5.el9.noarch.rpm
-rw-r--r--. 1 root     root      171015 Apr 21 15:15  mod_http2-2.0.26-2.el9_4.1.x86_64.rpm
-rw-r--r--. 1 root     root       61903 Apr 21 15:15  mod_lua-2.4.62-1.el9_5.2.x86_64.rpm
-rw-r--r--. 1 ec2-user ec2-user     561 Apr 21 13:55  reademe.md
-rw-r--r--. 1 root     root       18560 Apr 21 15:15  redhat-logos-httpd-90.4-2.el9.noarch.rpm

2. 패키지 이동 (인터넷 안되는 폐쇠망으로)

연습이기 때문에 이동했다 치고

 

3. 패키지 설치

sudo yum localinstall *.rpm

 

[ec2-user apache]$ sudo yum localinstall *.rpm
Updating Subscription Management repositories.
Unable to read consumer identity

This system is not registered with an entitlement server. You can use "rhc" or "subscription-manager" to register.

Last metadata expiration check: 0:07:46 ago on Mon 21 Apr 2025 03:12:48 PM KST.
Dependencies resolved.
==============================================================================================================================================================================================================
 Package                                               Architecture                              Version                                                Repository                                       Size
==============================================================================================================================================================================================================
Installing:
 apr                                                   x86_64                                    1.7.0-12.el9_3                                         @commandline                                    126 k
 apr-util                                              x86_64                                    1.6.1-23.el9                                           @commandline                                     97 k
 apr-util-bdb                                          x86_64                                    1.6.1-23.el9                                           @commandline                                     14 k
 apr-util-openssl                                      x86_64                                    1.6.1-23.el9                                           @commandline                                     17 k
 httpd                                                 x86_64                                    2.4.62-1.el9_5.2                                       @commandline                                     51 k
 httpd-core                                            x86_64                                    2.4.62-1.el9_5.2                                       @commandline                                    1.5 M
 httpd-filesystem                                      noarch                                    2.4.62-1.el9_5.2                                       @commandline                                     15 k
 httpd-tools                                           x86_64                                    2.4.62-1.el9_5.2                                       @commandline                                     86 k
 mailcap                                               noarch                                    2.1.49-5.el9                                           @commandline                                     35 k
 mod_http2                                             x86_64                                    2.0.26-2.el9_4.1                                       @commandline                                    167 k
 mod_lua                                               x86_64                                    2.4.62-1.el9_5.2                                       @commandline                                     60 k
 redhat-logos-httpd                                    noarch                                    90.4-2.el9                                             @commandline                                     18 k

Transaction Summary
==============================================================================================================================================================================================================
Install  12 Packages

Total size: 2.2 M
Installed size: 6.1 M
Is this ok [y/N]: y
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                                      1/1
  Installing       : apr-1.7.0-12.el9_3.x86_64                                                                                                                                                           1/12
  Installing       : apr-util-bdb-1.6.1-23.el9.x86_64                                                                                                                                                    2/12
  Installing       : apr-util-openssl-1.6.1-23.el9.x86_64                                                                                                                                                3/12
  Installing       : apr-util-1.6.1-23.el9.x86_64                                                                                                                                                        4/12
  Installing       : httpd-tools-2.4.62-1.el9_5.2.x86_64                                                                                                                                                 5/12
  Installing       : redhat-logos-httpd-90.4-2.el9.noarch                                                                                                                                                6/12
  Installing       : mailcap-2.1.49-5.el9.noarch                                                                                                                                                         7/12
  Running scriptlet: httpd-filesystem-2.4.62-1.el9_5.2.noarch                                                                                                                                            8/12
  Installing       : httpd-filesystem-2.4.62-1.el9_5.2.noarch                                                                                                                                            8/12
  Installing       : httpd-core-2.4.62-1.el9_5.2.x86_64                                                                                                                                                  9/12
  Installing       : mod_lua-2.4.62-1.el9_5.2.x86_64                                                                                                                                                    10/12
  Installing       : mod_http2-2.0.26-2.el9_4.1.x86_64                                                                                                                                                  11/12
  Installing       : httpd-2.4.62-1.el9_5.2.x86_64                                                                                                                                                      12/12
  Running scriptlet: httpd-2.4.62-1.el9_5.2.x86_64                                                                                                                                                      12/12
  Verifying        : apr-1.7.0-12.el9_3.x86_64                                                                                                                                                           1/12
  Verifying        : apr-util-1.6.1-23.el9.x86_64                                                                                                                                                        2/12
  Verifying        : apr-util-bdb-1.6.1-23.el9.x86_64                                                                                                                                                    3/12
  Verifying        : apr-util-openssl-1.6.1-23.el9.x86_64                                                                                                                                                4/12
  Verifying        : httpd-2.4.62-1.el9_5.2.x86_64                                                                                                                                                       5/12
  Verifying        : httpd-core-2.4.62-1.el9_5.2.x86_64                                                                                                                                                  6/12
  Verifying        : httpd-filesystem-2.4.62-1.el9_5.2.noarch                                                                                                                                            7/12
  Verifying        : httpd-tools-2.4.62-1.el9_5.2.x86_64                                                                                                                                                 8/12
  Verifying        : mailcap-2.1.49-5.el9.noarch                                                                                                                                                         9/12
  Verifying        : mod_http2-2.0.26-2.el9_4.1.x86_64                                                                                                                                                  10/12
  Verifying        : mod_lua-2.4.62-1.el9_5.2.x86_64                                                                                                                                                    11/12
  Verifying        : redhat-logos-httpd-90.4-2.el9.noarch                                                                                                                                               12/12
Installed products updated.

Installed:
  apr-1.7.0-12.el9_3.x86_64              apr-util-1.6.1-23.el9.x86_64                 apr-util-bdb-1.6.1-23.el9.x86_64        apr-util-openssl-1.6.1-23.el9.x86_64     httpd-2.4.62-1.el9_5.2.x86_64
  httpd-core-2.4.62-1.el9_5.2.x86_64     httpd-filesystem-2.4.62-1.el9_5.2.noarch     httpd-tools-2.4.62-1.el9_5.2.x86_64     mailcap-2.1.49-5.el9.noarch              mod_http2-2.0.26-2.el9_4.1.x86_64
  mod_lua-2.4.62-1.el9_5.2.x86_64        redhat-logos-httpd-90.4-2.el9.noarch

Complete!

 

 

4. 설치 확인, enable, start

# 다운로드 확인 
sudo systemctl status httpd

# 재기동 시 자동 시작 서비스 등록
sudo systemctl enable httpd

# httpd 시작
sudo systemctl start httpd
[ec2-user apache]$ sudo systemctl status httpd
○ httpd.service - The Apache HTTP Server
     Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; preset: disabled)
     Active: inactive (dead)
       Docs: man:httpd.service(8)
[ec2-user apache]$ sudo systemctl enable httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
[ec2-user apache]$ sudo systemctl start httpd
[ec2-user apache]$ sudo systemctl status httpd
● httpd.service - The Apache HTTP Server
     Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; preset: disabled)
     Active: active (running) since Mon 2025-04-21 15:22:41 KST; 1min 15s ago
       Docs: man:httpd.service(8)
   Main PID: 12504 (httpd)
     Status: "Total requests: 0; Idle/Busy workers 100/0;Requests/sec: 0; Bytes served/sec:   0 B/sec"
      Tasks: 177 (limit: 47887)
     Memory: 22.4M
        CPU: 117ms
     CGroup: /system.slice/httpd.service
             ├─12504 /usr/sbin/httpd -DFOREGROUND
             ├─12505 /usr/sbin/httpd -DFOREGROUND
             ├─12506 /usr/sbin/httpd -DFOREGROUND
             ├─12507 /usr/sbin/httpd -DFOREGROUND
             └─12508 /usr/sbin/httpd -DFOREGROUND

Apr 21 15:22:41 ip-172-31-55-140.ap-northeast-2.compute.internal systemd[1]: Starting The Apache HTTP Server...
Apr 21 15:22:41 ip-172-31-55-140.ap-northeast-2.compute.internal httpd[12504]: Server configured, listening on: port 80
Apr 21 15:22:41 ip-172-31-55-140.ap-northeast-2.compute.internal systemd[1]: Started The Apache HTTP Server.
[ec2-user apache]$

 

 

5. CURL로 확인해보기

curl localhost:80

 

6. 브라우저로 확인

6-1 배스천 서버의 설정

현재 서버는 private IP로만 구성 되어 있으며 접근은 베스쳔 서버부터 타고 들어가야한다.

ssh 접근도 bastion 서버부터 접근한다

 

local -> bastion(public IP) -> apache(private IP)

내 로컬에서 apache를 접근하기 위해서는 bastion에 설정이 필요하다.

 

local에서 mobaxterm을 사용하여 터널링을 진행

터널링 클릭

 

New ssh tunnel 클릭

 

내가 사용할 포트(9999), 베스천 아이피, 베스천 아이디, 아파치 서버의 IP , 아파치 서버 포트 

설정 후 저장

 

베스천의 ppk지정하기 위해 열쇠 모양 클릭 후 ppk 등록

 

실행

 

localhost:9999 접속

 

설명과 같이 html 정적 파일은 "/var/www/html"에 두고 

설정 파일은 "/etc/httpd/conf.d/welcome.conf"에 설정하면 된다.

0. 업무 중 불편사항

 

업무중 여러 설정 정보를 취합 하여 전달하는 API가 존재 한다.

해당 정보들은 RDB에 저장되어 있으며 일반적으로는 1개의 row가 존재하는 마스터 테이블이다.

 

해당 데이터들은 변경이 필요하지만 자주 변경은 되지않으므로 CRUD를 위하여 WEB과 API가 필요하다.
Ex) A 설정정보를 위해 A테이블에 대한 API CRUD와 WEB 개발 (데이터 1건)

B 설정정보를 위한 B 테이블에 대한 API CRUD와 WEB 개발 (데이터 1건)

C 설정정보를 위한 C 테이블에 대한 API CRUD와 WEB 개발 (데이터 1건)

... 등등등

단 해당 데이터들은 반드시 1건은 아니며 최대 5건 내외 정도 될 듯 하다 (3건 이상은 못 본듯 하지만 설계상 가능)

 

해당 건들을 조건에 따라 조합하여 1개의 종합 설정정보를 만들어 API로 전달한다.

 

위 데이터들을 위해 CRUD API와 WEB 개발 하는 것은 불필요해 보이며, 변동이 적고, 조건에 따른 조합이 필요했다.

 

이를 위해 WorkFlow를 도입하여 테스트 해보고자 했다

 


1. Node-Red 란 무엇인가.

Node-RED(노드 레드)는 하드웨어 장치들, API, 온라인 서비스를 사물인터넷의 일부로 와이어링(배선화)시키기 위해 본래 IBM이 개발한 시각 프로그래밍을 위한 플로 기반 개발 도구이다.

Node-RED는 브라우저 기반 플로 편집기를 제공하므로 자바스크립트 함수를 개발하는데 사용할 수 있다. 애플리케이션의 요소들은 재사용을 위해 저장하거나 공유할 수 있다. 런타임은 Node.js 위에서 개발되어 있다. Node-RED에서 만든 플로는 JSON을 사용하여 저장된다. 버전 0.14 이후 MQTT 노드들은 적절하게 구성된 TLS 연결을 만들 수 있다.

2016년에 IBM은 Node-RED를 오픈 소스 "JS Foundation" 프로젝트로 기여했다.

출처 위키백과

 


2. Node-Red 설치

2-1. 도커 설치

  • 추후 docker compose로 구성하여 volume 또한 잡아주어야 관리가 용이하다.
docker run -it -p 1880:1880 -v node_red_data:/data --name mynodered nodered/node-red

 

2-2. 로컬 설치

  • 주의 Node.js 설치가 필요하다.
npm install -g --unsafe-perm node-red

 

실행

node-red

 

 

접속

브라우저에서 http://localhost:1880

 


3. Node-Red에서 RestAPI 테스트

왼쪽의 팔레트에서 http in, function, http response를 드래그하여 플로우 화면에 이동 시킨 후 각 컴포넌트들을 연결한다.

 

 

 

http in을 더블클릭하여 수정

 

function을 클릭하여 수정

 

http response 수정 후 오른쪽 상단의 배포하기 클릭

 

 

http://localhost:1880/apiTest로 테스트


4. 추가 컴포넌트 설치

시간에 따른 분기처리하는 컴포넌트가 기본으로 제공 되지 않는다.

 

오른쪽의 = 메뉴 > 팔렛트 관리 > 설치 가능한 노드 > node-red-contrib-time-switch 검색 > 설치

 

 

기능 노드 > time switch가 생긴 것을 확인 할 수 있다.


5. 샘플 설정 API 구성해보기

5-1. 전체 구성

 

5-2. 구성 설명

  1. request로 codeValeu를 받는다.
  2. codeValue별 projectId를 다르게 세팅한다.(스위치 노드 사용하여 분기)
  3. target을 설정하는데 나중에 변경 할 수 있도록 A노드를 만들어두고 연결을 끊어둔다.(미사용 처리)
  4. 현재 시간에 따라 ment를 세팅한다. (타임 스위치 노드 사용하여 분기)

5-3. 테스트


6. 내보내기/가져오기

 

현재플로우/ 전체 플로우를 export, import가 가능하다. 해당 데이터는 json으로 만들어지며 파일/클립보드 형식으로 사용할 수있다.

 

테스트 샘플 json 공유

[
    {
        "id": "389108cf5e372918",
        "type": "tab",
        "label": "API 테스트",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "5c24f9ea6863049d",
        "type": "http in",
        "z": "389108cf5e372918",
        "name": "propertiesSetting",
        "url": "/apiTest",
        "method": "get",
        "upload": false,
        "swaggerDoc": "",
        "x": 200,
        "y": 260,
        "wires": [
            [
                "691f00ddb0f0f4d1"
            ]
        ]
    },
    {
        "id": "691f00ddb0f0f4d1",
        "type": "switch",
        "z": "389108cf5e372918",
        "name": "code 별 분기처리",
        "property": "payload.codeValue",
        "propertyType": "msg",
        "rules": [
            {
                "t": "btwn",
                "v": "10001",
                "vt": "num",
                "v2": "10005",
                "v2t": "num"
            },
            {
                "t": "btwn",
                "v": "10006",
                "vt": "num",
                "v2": "10010",
                "v2t": "num"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 430,
        "y": 260,
        "wires": [
            [
                "dd2e6d4c3f91d1a1"
            ],
            [
                "8d56be140949ad6c"
            ]
        ]
    },
    {
        "id": "dd2e6d4c3f91d1a1",
        "type": "function",
        "z": "389108cf5e372918",
        "name": "projectNum01",
        "func": "msg.payload.projectId='projectNum01'\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 660,
        "y": 220,
        "wires": [
            [
                "23994dbc840a7ce6"
            ]
        ]
    },
    {
        "id": "411363cd9bd10a0c",
        "type": "comment",
        "z": "389108cf5e372918",
        "name": "A 설정 세팅(projectId)",
        "info": "",
        "x": 680,
        "y": 160,
        "wires": []
    },
    {
        "id": "8d56be140949ad6c",
        "type": "function",
        "z": "389108cf5e372918",
        "name": "projectNum02",
        "func": "msg.payload.projectId='projectNum02'\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 660,
        "y": 300,
        "wires": [
            [
                "bbf5e59569ef9c5e"
            ]
        ]
    },
    {
        "id": "23994dbc840a7ce6",
        "type": "function",
        "z": "389108cf5e372918",
        "name": "target(local)",
        "func": "msg.payload.targetUrl='localhost'\nmsg.payload.targetPort='8080'\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 970,
        "y": 220,
        "wires": [
            [
                "735dd47aa923edda"
            ]
        ]
    },
    {
        "id": "8db7557e970a9a9d",
        "type": "comment",
        "z": "389108cf5e372918",
        "name": "B 설정 세팅(target)",
        "info": "",
        "x": 950,
        "y": 160,
        "wires": []
    },
    {
        "id": "21a72f6b7be84d83",
        "type": "function",
        "z": "389108cf5e372918",
        "name": "target(serverA)",
        "func": "msg.payload.targetUrl='http:serverA.com'\nmsg.payload.targetPort='8081'\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1180,
        "y": 280,
        "wires": [
            [
                "735dd47aa923edda"
            ]
        ]
    },
    {
        "id": "bbf5e59569ef9c5e",
        "type": "function",
        "z": "389108cf5e372918",
        "name": "target(ServerB)",
        "func": "msg.payload.targetUrl = 'http:serverB.com'\nmsg.payload.targetPort='8082'\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 980,
        "y": 340,
        "wires": [
            [
                "735dd47aa923edda"
            ]
        ]
    },
    {
        "id": "b584ee422c183395",
        "type": "comment",
        "z": "389108cf5e372918",
        "name": "C 설정 세팅 분기 (ment)",
        "info": "",
        "x": 240,
        "y": 440,
        "wires": []
    },
    {
        "id": "735dd47aa923edda",
        "type": "time-switch",
        "z": "389108cf5e372918",
        "name": "근무시간 여부",
        "lat": "37.564214",
        "lon": "127.001699",
        "startTime": "09:00",
        "endTime": "18:00",
        "startOffset": "0",
        "endOffset": 0,
        "x": 140,
        "y": 500,
        "wires": [
            [
                "2117890feccac6aa"
            ],
            [
                "4e28e016aecb2cd3"
            ]
        ],
        "outputLabels": [
            "근무시간",
            "근무 외 시간"
        ]
    },
    {
        "id": "2117890feccac6aa",
        "type": "function",
        "z": "389108cf5e372918",
        "name": "근무시간",
        "func": "msg.payload.ment=\"근무시간 입니다.\"\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 440,
        "y": 480,
        "wires": [
            [
                "6b3c1c70b041e627"
            ]
        ]
    },
    {
        "id": "4e28e016aecb2cd3",
        "type": "function",
        "z": "389108cf5e372918",
        "name": "근무외 시간",
        "func": "msg.payload.ment=\"근무외 시간입니다.\"\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 450,
        "y": 540,
        "wires": [
            [
                "6b3c1c70b041e627"
            ]
        ]
    },
    {
        "id": "6b3c1c70b041e627",
        "type": "http response",
        "z": "389108cf5e372918",
        "name": "",
        "statusCode": "200",
        "headers": {},
        "x": 720,
        "y": 500,
        "wires": []
    },
    {
        "id": "cf30e87595d4e294",
        "type": "comment",
        "z": "389108cf5e372918",
        "name": "C 설정 세팅(ment)",
        "info": "",
        "x": 450,
        "y": 440,
        "wires": []
    }
]

Vue2 코드에서 Vue3로 변경하는 작업을 진행해야 하는 일이 생겼다.

변경 작업을하며 Node의 버전도 올려야 하는데 두 소스 모두 기동하면서 비교하면서 작업을 진행해야한다.

 

vscode에 .vscode 디렉토리 생성 후 

settings.json 생성

{ 
"terminal.integrated.env.windows" : { "PATH": {node 설치 경로}}

}

 

 

대용량 데이터를 생성하고 다운로드 하는 api가 있는데 데이터가 늘어나다보니 60초 이상이 걸리고 api에서는 timeout이 발생하여 결과를 받지 못하는 상황이 생겼다.

 

개발환경에서 테스트를 하기위해 임시 api를 만든다.

 

url로 /public/10 과같이 값을 입력 받아 Thread.sleep으로 강제 지연을 발생 시킨다.

@Controller
@RequestMapping(value = "/public")
public class HealthController {

	@GetMapping("/{time}")
    public ResponseEntity healthCheck(@PathVariable("time") long time) {
    	try {
        	Thread.sleep(time * 1000L)
        }catch (Exception e) {
        	e.printStackTrace();
        }
    }

}

 

 

nginx의 설정 추가

proxy_read_timeout은 nginx가 백엔드로부터 응답을 받기까지 대기하는 시간이다. 즉 client는 nginx로 요청을 보내고 nginx는 client의 요청을 다시 backend로 보내는데 nginx와 backend 통신이 proxy_read_timeout 기간내로 결과를 주지 못한다면 연결을 끊는다는 의미다.(default는 60초이다.)

location ^~ /public/ {
....
	proxy_read_timeout 120;
....
}

 

변경전에는 /public/61 으로 테스트 할 때 timeout이 발생하였으나, 변경 후 정상적으로 데이터를 받아온느 것을 확인하였다

 

추가적으로 axios(혹은 ajax), tomcat 등의 설정에서 nginx보다 더 작은 값의 timeout이 설정되어 있다면 가장 작은 값을 따라감으로 추가적인 확인이 필요하다.

 

+ Recent posts